mrbhb Posted December 19, 2013 Share Posted December 19, 2013 I have problem need help that, I have a form have 1 select filed and 1 text field, I want when I choose value in option of select the text field will load/appear value in proportion to value of select, example in picture when I choose "B" in select field, the value in text filed will appear "1", so how to do it, I need example to refer, guide or demo example, Thank for read my topic Here is Image Code <head> <title>Untitled Document</title> <style type="text/css"> </style> </head> <body> <center> <br /> <form id="cv" action="" method=""> Choose Option: <select id="chedo"> <option>--Choose Value--</option> <option>A</option> <option>B</option> <option>C</option> </select> <br /> <br /> Value: <input type="text" id="lenh" size="40"/> <br /> <br /> <input type="submit" value="SUBMIT"/> </form> </center> </body> </html> Quote Link to comment Share on other sites More sharing options...
scootstah Posted December 19, 2013 Share Posted December 19, 2013 You need to do that with Javascript. Here is the doc page for jQuery's .change() : http://api.jquery.com/change/ Quote Link to comment Share on other sites More sharing options...
mrbhb Posted December 19, 2013 Author Share Posted December 19, 2013 thank for read and help of everyone, you need to add jQurey library and here is code <script type="text/javascript" language="javascript"> $("#chedo").change(function(){ var selected = $("#chedo").val(); $("#lenh").val(selected); }); </script> Quote Link to comment Share on other sites More sharing options...
scootstah Posted December 19, 2013 Share Posted December 19, 2013 Additionally, add .change() to your selector to trigger the change event on the initial page load. $("#chedo").change(function(){ var selected = $("#chedo").val(); $("#lenh").val(selected); }).change(); 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.