avenger108 Posted October 6, 2007 Share Posted October 6, 2007 hello everyone, i need some advice... my problem is i want to update two <div> after i click a button... this is the scenario... i have insert a number '5' and then i click submit button... once i click the submit button, i want to display : that number '5' in <div id="one"> , and total amount '5*300' in <div id="second"> ... please help me how to do that... thank you... Quote Link to comment Share on other sites More sharing options...
bobleny Posted October 7, 2007 Share Posted October 7, 2007 This may or may not be what you are looking for, and this probably isn't the best way to do this, but it works... Hope this helped. <html> <body> <script type="text/javascript"> var foo function Return(num) { foo = num; } function Check() { document.getElementById("one").innerHTML = foo; document.getElementById("second").innerHTML = foo*300; } </script> <input name="number" onkeyup="Return(this.value)" type="textbox" /><br /> <input type="button" onclick="Check()" value="Click me Now!" /><br /><br /> Number Entered: <span id="one"></span><br /> Total Amount: <span id="second"></span><br /> </body> </html> Quote Link to comment Share on other sites More sharing options...
avenger108 Posted October 12, 2007 Author Share Posted October 12, 2007 i've try to modify your coding... like this... <html> <body> <script type="text/javascript"> var foo function Check() { document.getElementById("one").innerHTML = Check1(); document.getElementById("second").innerHTML = Check2(); } function Check1() { foo = encodeURI( document.getElementById("number").value ); } function Check2() { document.getElementById("second").innerHTML = encodeURI( document.getElementById("number").value )*300; } </script> <input name="number" id="number" type="textbox" /><br /> <input type="button" onclick="Check()" value="Click me Now!" /><br /><br /> Number Entered: <span id="one"></span><br /> Total Amount: <span id="second"></span><br /> </body> </html> but the answer is like this.... Number Entered: undefined Total Amount: undefined .....can you help me how to solve this.... Quote Link to comment Share on other sites More sharing options...
avenger108 Posted October 12, 2007 Author Share Posted October 12, 2007 ops...sorry... i've already found the answer...this is my new code... <html> <body> <script type="text/javascript"> var foo function Check() { document.getElementById("one").innerHTML = Check1(); document.getElementById("second").innerHTML = Check2(); } function Check1() { foo = encodeURI( document.getElementById("number").value ); return foo; } function Check2() { foo2 = encodeURI( document.getElementById("number").value )*300; return foo2; } </script> <input name="number" id="number" type="textbox" /><br /> <input type="button" onclick="Check()" value="Click me Now!" /><br /><br /> Number Entered: <span id="one"></span><br /> Total Amount: <span id="second"></span><br /> </body> </html> thank you very much 4 your help bro.... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.