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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change values of listboxes onclick

Status
Not open for further replies.

moley

IS-IT--Management
Mar 26, 2002
95
GB
Hi,

I have a form with a group of list boxes under different headings. I'm trying to get all the boxes to change to N/a on click of a button or text. Can anyone shed some light?

<!--
function Notapplic(theDiv){
var na = document.getElementById(theDiv);
na.value = (na.value ==&quot;3&quot;)?&quot;&quot;:&quot;3&quot;;
na.style.background = &quot;#FFFFFF&quot;
//-->
}

<a href=&quot;#&quot; onclick=&quot;Notapplic('sm0') ;return;>N/A</a>
<select name=&quot;cboSM1&quot; id=sm0 onChange=&quot;cboBkgdChange(this)&quot;>
<option value=&quot;0&quot; selected> </option>
<option value=&quot;1&quot;>Yes</option>
<option value=&quot;2&quot;>No</option>
<option value=&quot;3&quot;>N/a</option>
</select>

<select name=&quot;cboSM2&quot; id=sm0 onChange=&quot;cboBkgdChange(this)&quot;>
<option value=&quot;0&quot; selected> </option>
<option value=&quot;1&quot;>Yes</option>
<option value=&quot;2&quot;>No</option>
<option value=&quot;3&quot;>N/a</option>
</select>
 
can't have 2 of the same IDs....


function Notapplic(){
var na = document.getElementsByTagName(&quot;select&quot;);
for (x=0; x<na.length; x++){
if (na[x].name.substr(0,5) == &quot;cboSM&quot;){
na[x].selectedIndex = 3
}
}
}

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

zen.gif
 
Thanks that did the trick,

Cheers

moley
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top