I have a script, where I am trying to use a variable and then there is a text field, where I am able to input numbers and then when click on the "Submit" button, I want to add "Input" to the variable, only one problem is that to display the variable to my code Will not work.
My code (Html):
& lt; Form id = "form" onsubmit = "return false;" & Gt; & Lt; Input style = "width: 100px;" Type = "text" id = "input" /> & Lt; Input style = "width: 100px;" Type = "submit" id = "submit" click "getclip =" getInput (); / / Gt; & lt; / form & gt; & lt; a href = "#" & gt; The current amount is: & lt; span id = "zodiac sofar" & gt; & lt; / span & gt;
My code (javascript):
var sumber: int = 1; function getInput () {var input = Document.getElementById ("input"); value; zodiac sofra = soff + input; warning (input);}
my code (css):
# input {status: full; top: 100px; margin-left: -100px; left: 50%;} #submitBut {status: full; top: 120px; margin-left: -100px; left: 50%; }
var amount soFar = 1; $ ('# form'). Submit (function) {event.preventDefault (); var input = $ ('#input'). Val (); Zodiac SOffer = parseInt (amountSoFar) + parseInt (input); $ ('#amountSoFar'). Text (Zodiac SOFFER);});
# input {status: complete; Top: 100px; Margin-left: -100px; Left: 50%; } #submitBut {status: complete; Top: 120px; Margin-left: -100px; Left: 50%; }
& lt; Form id = "form" onsubmit = "return false;" & Gt; & Lt; Input style = "width: 100px;" Type = "text" id = "input" /> & Lt; Input style = "width: 100px;" Type = "submit" id = "submit" /> & Lt; / Form & gt; & Lt; A href = "#" & gt; The current amount is: & lt; Span id = "zodiac sofar" & gt; & Lt; / Span & gt; & Lt; / A & gt;
CSS and JS are similar to your original example. JS was triggered on $ ('# form'). Submit ()
so that it worked with the key too. It was also updated to update live values on the page.
Working JS Field:
No comments:
Post a Comment