HTML - Calling Javascript Function with variable? [closed] - javascript

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
So I am trying to do a button and if you click on it then it calls a function called order(). So, If I'm trying to do something like this order("+<script>blablabla</script>+") then it shows me a error if I type into something between the "+HERE+" Why that? Is there any way around it?

You could always do something like this. Maybe change the divs around a bit and add a rounding system. This gives you a live update on the costs when selecting how many keys.
https://jsfiddle.net/8hube9ua/
Throw this under your select,
<span data-val="1.85">1.85</span> <!--How much each key is-->
then throw this into the script.
<script>
$('#suiface').change(function(){
var span = $(this).next('span');
span.text(span.data('val') * parseInt(this.value,10)) //multiplies the cost by the option selected
})
</script>

I'm not sure to understand, but why don't you write something like this ?
<button onclick="order()">Blablabla</button>

Related

How do I output a variable from JavaScript to HTML [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
enter image description here
1)Make up the design below
2)License type output in Bebas font-output via font-face
3)Display the selected license type and total amount
4)The format of the link in the Buy Now button is formed at your discretion
(How to execute an item highlighted in italics)
You need to have an HTML element (like a paragraph) where you want to display the amount.
If you give the element an id attribute with the value "my-paragraph", then your script can get the element like myParagraph = document.getElementById("my-paragraph").
Then you can change the content of the element like myParagraph.textContent = myAmount.
Begin your learning journey on MDN: https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Introduction

Custom hover popup in HTML/JS/CSS [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
How would one be able to get a popup like the image below on hover of an element? I'm not sure what I should be adding in here apart from that I preferably don't want to use any other libraries apart from jquery. Please tell me if you need any code snippets or any more information!
Let's say you have said element above as a div on your page with an ID of 'cursor'. You can set the display value in your css to 'hidden', so it won't be displayed at first. When you hover over another element, you can trigger functions to display or hide said element:
<div id='hover-element' onmouseover='onMouseOver()' onmouseout='onMouseOut()'></div>
<div id=cursor'</div>
And then inside those functions:
function onMouseOver(element){
document.getElementById('cursor').style.display = 'block';
}
function onMouseOut(element) {
document.getElementById('cursor').style.display = 'none';
}
Try it :)

unable to deal with empty field in my code [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
Here I need to provide officename to find the address ,but one challenge which I am facing that if user does not type anything and hit search button then I want to acknowledge them to fill the req input.
I have implemented one function also that will get invocked when someone hits the search button.But I am unable to proceed for further execution.
You can do it something like this:
var searchText = document.getElementById('<ID_OF_INPUT_FIELD>').value;
if(!searchText) {
alert('Please enter something');
}
<input id =“officeInput” name=“officeiupit” size=“35”>
Point to critical input fields and save in global variables:
oOf=document.getElementById(‘officeInput’);
When a search button has been clicked, make a copy of the textbook content inside your function which you've made:
var sInputText=oOf.value;
In this case inside your function just put
if(!sInputText)
alert(“You must enter an input.“);

how to create random dynamic links in javascript? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Hi I am new to web dev world. I am trying to write a code where I can get dynamic links.
Like after the ? in a url I want to generate random numbers so every time a user goes to the website it will make a call to the server and not use the cache.
The best way for your requirement would be to append system time in milli second instead of random number as random number can be the same.
You can use as -
<div ng-app ng-controller="Ctrl">
<a ng-href="url/?no={{time}}">link</a>
</div>
function Ctrl($scope)
{
$scope.time = new Date().getTime();
}
In angularjs you can use nghref directive https://docs.angularjs.org/api/ng/directive/ngHref
Something like this:
// html
<a ng-href="someurl/?rand={{getRand()}}">link</a>
// angular controller
$scope.getRand = function() {
return Math.floor(Math.random()*100000)
}

Dynamically add array textbox in a form [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I need to add in all the textbox manually in my project.
<form>
<?php for($i=0;$i<3;$i++){ ?>
<input type="text" name="product[]">
<?php } ?>
</form>
how can i solve this problem so that the number of product for insert can be flexible.
For example, user1 need to purchase 4 item, user2 wan to purchase 8 item. wihtout dynamic textbox, i need to add the textbox manually by adjusting the looping value (in my coding).
It sounds like this is an update to customer products right?
if so, you probably have products array somewhere.
so you might do :
$products = $customer->products ;//or your array
for($i=0;$i<count($products);$i++){
// your code
}
or you can add it via javascript (sounds more like it if this is the purchase moment - new products, not update)
or you might want to have somewhere a config per customer.
or Please be more specific and more descriptive

Categories