DarkPrince2005 Posted March 21, 2008 Share Posted March 21, 2008 Can somebody please help me with a script? i've got a drop down box in a form, but i want to auto generate the text in 3 textboxes depending on the selection made. e.g. if option 1 is selected the first textboxes text should be set to 150, and the second 250, and the third should show the sum of the first and second textboxes values. Quote Link to comment Share on other sites More sharing options...
gruzaw Posted March 25, 2008 Share Posted March 25, 2008 this is not really a html question, try the javascript forum Quote Link to comment Share on other sites More sharing options...
thomashw Posted March 25, 2008 Share Posted March 25, 2008 Yeah, check out Javascript. Quote Link to comment Share on other sites More sharing options...
zenag Posted March 27, 2008 Share Posted March 27, 2008 check this out... <html> <head> <script type="text/javascript"> function favBrowser() { var mylist=document.getElementById("myList"); if(document.getElementById("myList").options.selectedIndex==0) { document.getElementById("favorite").value=mylist.options[mylist.selectedIndex].text; } else if(document.getElementById("myList").options.selectedIndex==1) {document.getElementById("favorite1").value=mylist.options[mylist.selectedIndex].text; } if(document.getElementById("favorite1").value!="" && document.getElementById("favorite").value!="") { //alert(parseInt(document.getElementById("favorite").value )+parseInt(document.getElementById("favorite1").value)); document.getElementById("favorite2").value=parseInt(document.getElementById("favorite").value )+parseInt(document.getElementById("favorite1").value) } } </script> </head> <body> <form> Select your favorite browser: <select id="myList" onchange="favBrowser()"> <option>100</option> <option>200</option> </select> <p> <input type="text" id="favorite" size="20"></p> <p> <input type="text" id="favorite1" size="20"></p> <p> <input type="text" id="favorite2" size="20"></p> </form> </body> </html> 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.