Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

change a form drop down menu's value at onClick

Status
Not open for further replies.

vionca

MIS
Nov 19, 2003
60
US
Hi there,

I'm having trouble finding a way to simply set a drop down menu's value on my form to automatically be set to 'na' when a particular link is clicked.

Does anyone here know if this is possible?

vionca
 
Is 'na' a value you can already choose in your dropdown? If so, formname.selectname.value = 'na' will suffice. If not you'll have to add an option to your pulldown and set it as selected.

-kaht

banghead.gif
 
I can't seem to get this to work. Could it be the fact that I am using layers? I tried to make the code as legible as possible.

Here's my code:

For the layer containing the drop down menu:

<div id=&quot;jobNumLYR&quot; style=&quot;position:absolute; width:600; height:1px; z-index:1; left: 139px; top: 920px; visibility: hidden;&quot;>

<table width=&quot;671&quot; border=&quot;0&quot; cellspacing=&quot;3&quot; cellpadding=&quot;3&quot;>
<tr>
<td width=&quot;329&quot;><div align=&quot;center&quot;><font size=&quot;3&quot;><strong><u>Job Number</u> </strong> </font> </div>
</td>
</tr>
<tr>
<td width=&quot;300&quot; height=&quot;52&quot;>
<div align=&quot;center&quot;> <font size=&quot;2&quot;>Starting Job Number: </font>
<select name=&quot;startjobNum&quot; id=&quot;jobNum&quot;>
<option value=&quot;na&quot; selected>n/a</option>
<option value=&quot;all&quot;>ALL</option>
</select>
</div>
</td>
</div>

Now, my onClick is not on any layer at all and it's code is:

<p>
<a href=&quot;#&quot;
onClick= &quot;javascript: SoLYR.style.visibility='visible'; WoLYR.style.visibility='hidden'; jobNumLYR.style.visibility='hidden'; amtDueLYR.style.visibility='hidden'; buttons1.style.visibility='hidden'; form.jobNum='na';&quot;>
<font size=&quot;2&quot;>Sales Order Number
</font>
</a>
</p>
 
You could use InnerHTML. It works in IE, but not sure about Netscape.
Example:
function checkfollowup()
{
divNAME.innerHTML = '<input type=&quot;input&quot; name=&quot;field1_in&quot; size=&quot;12&quot; value&quot;na&quot;>');
}

Then call your function from your link, or use an onChange or onClick.

And have your div named to whatever &quot;divNAME&quot; is above.

<div id=&quot;divNAME&quot;><input type=&quot;input&quot; name=&quot;field1_in&quot; size=&quot;12&quot; value&quot;someothervalues&quot;></div>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top