View Single Post
  #15 (permalink)  
Old 10-19-2007, 05:04 AM
Pvinothkumar Pvinothkumar is offline
D-Web Analyst
 
Join Date: Sep 2007
Posts: 237
Pvinothkumar is on a distinguished road
Default How can I compare two selected items from two different select form fields?

Hi all...


<SCRIPT LANGUAGE="JavaScript"><!--
function test(what) {
if (what.select1.options[what.select1.selectedIndex].value == what.select2.options[what.select2.selectedIndex].value)
alert('They are the same');
}
--></SCRIPT>

<FORM NAME="myForm">

<SELECT NAME="select1">
<OPTION VALUE="abc">123
<OPTION VALUE="def">456
<OPTION VALUE="ghi">789
</SELECT>


<SELECT NAME="select2">
<OPTION VALUE="abc">123
<OPTION VALUE="def">456
<OPTION VALUE="ghi">789
</SELECT>

<INPUT TYPE="BUTTON" VALUE="SUBMIT" onClick="test(this.form)">

</FORM>

Thanks....
Reply With Quote