Suchy Posted February 10, 2008 Share Posted February 10, 2008 I have a nice javascript that instantly displays contents of selected item from a dropdown menu inside a div. <select name="operator" onChange="displaydesc(document.form1.operator, operator_status, 'show_info')"> ... <div id="'show_info"></div> Now how can I make the info appera inside a text input field, setting its id to show_info does not work. ?? Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted February 10, 2008 Share Posted February 10, 2008 Post your full code and I implement it to do what you are wanting it to do. Quote Link to comment Share on other sites More sharing options...
Suchy Posted February 10, 2008 Author Share Posted February 10, 2008 <script type="text/javascript"> var operator_status=new Array() operator_status[0]="Verizon" operator_status[1]="Sprint" ....... operator_status[50]="Plus GSM" function displaydesc(which, descriptionarray, container) { if (document.getElementById) document.getElementById(container).innerHTML=descriptionarray[which.selectedIndex] } function jumptolink(what) { var selectedopt=what.options[what.selectedIndex] if (document.getElementById && selectedopt.getAttribute("target")=="newwin") window.open(selectedopt.value) else window.location=selectedopt.value } displaydesc(document.form1.operator, operator_status, 'show_info') </script> dropdown menu looks like: <select name="operator" onChange="displaydesc(document.form1.operator, operator_status, 'show_info')"> <option>Verizon</option> <option>Sprint</option> ...... The info is displayed inside a div: <div id="'show_info"></div> I want the info to be displayed inside a text field: You selected: <br><input name="show_info" type="text" id="show_info" > Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted February 10, 2008 Share Posted February 10, 2008 Not quit sure what the heck you were trying to do with the code you provided; but try this instead. <div id="show_info"></div> <form name="form1"> You selected: <select name="operator" onChange="displaydesc('show_info',this.value)"> <option>Verizon</option> <option>Sprint</option> </select> <br><input name="show_info" type="text" id="show_info" > </form> <script language="javascript"> function displaydesc(which,what) { var showstuff = document.getElementById(which).innerHTML = what; document.form1.show_info.value = showstuff; } </script> 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.