Namal Posted December 22, 2006 Share Posted December 22, 2006 There is a function call "myvalue()" in my external javascript file. (tst.js)There are button call " Test" and input textbox call (ID) "txttotal" in my HTML file.I want to do following:Click on the "Test" button, The "txttotal" value will be "10"How can I do that?... Please explain that soon. Link to comment Share on other sites More sharing options...
aspnetguy Posted December 22, 2006 Share Posted December 22, 2006 <html><head> <title></title> <script> function myvalue() { var textbox = document.getElementById('txttotal'); textbox.value = 10; } </script></head><body> <form id="form1"> <input type="text" id="txttotal" value=""/><br/> <input type="button" id="btntest" value="Test" onclick="myvalue()"/> </form></body></html> Link to comment Share on other sites More sharing options...
Sniffy Posted December 22, 2006 Share Posted December 22, 2006 Also, you can use javascript void(0). <html><head></head><body><input type='text' id='txtvalue' value=""><a href='java script: document.getElementById("txtvalue").value = "10";'>Click me</a></body></html> Link to comment Share on other sites More sharing options...
aspnetguy Posted December 22, 2006 Share Posted December 22, 2006 inline js is messy and hard to maintain, plus java script:void(0) does nothing, the code you wrote is not java script:void(0) Link to comment Share on other sites More sharing options...
Sniffy Posted December 22, 2006 Share Posted December 22, 2006 Wait, void(0) means return(nothing) do yeah, you're right.I just posted another solution just for the guy to learn by. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now