Jump to content

Input field


Suchy

Recommended Posts

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.

 

 

??

Link to comment
https://forums.phpfreaks.com/topic/90301-input-field/
Share on other sites

<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"  >

 

Link to comment
https://forums.phpfreaks.com/topic/90301-input-field/#findComment-463034
Share on other sites

 

Not quit sure what the heck you were trying to do with the code you provided; but try this instead. :D

 

<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>

Link to comment
https://forums.phpfreaks.com/topic/90301-input-field/#findComment-463081
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.