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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.