View Full Version : onClick doesn't work in a SELECT tag
SpecialK-MI
05-25-2004, 09:27 AM
Anyone know why onClick in a SELECT tag works in Netscape but not in Internet Explorer? I'm using IE 5.5 and Netscape 7.1. I have also tested it in IE 6.0 and get the same result (it doesn't work).
Goldilocks
05-25-2004, 09:30 AM
Don't know, are you able to use onchange instead?
SpecialK-MI
05-25-2004, 10:24 AM
Here's the code:
This appears betweem the <HEAD> </head> :
<script language="Javascript">
function openInfoWindow(file)
{
window.open(file,'InfoWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,resizable= yes,copyhistory=no,scrollbars=yes,width=640,height=480,screenX=10,screenY=10,top=10,left=10');
}</script>
Then in the <BODY> ....
<FORM>
<CENTER>
<TABLE>
<TR>
<TD WIDTH=200><B>Topic</B></td><TD><B>Time Frame</B></td></tr>
<TR>
<TD>Debt Management</td>
<TD><SELECT NAME="DebtMgt">
<OPTION VALUE="blank">Select a Time Frame
<OPTION VALUE="hs">High School
<OPTION VALUE="college" onClick="openInfoWindow('DMCFrames.htm');">College
<OPTION VALUE="grace">Grace Period
<OPTION VALUE="Repay">Repayment
<OPTION VALUE="Default">Default
<OPTION VALUE="NA">N/A
</SELECT></td></tr></table>
</form>
Thanks for any input you can give me. emember ... I'm a novice at best!!!!
Also ... if I were to set up an "if" statement ... how would I say ... if DebtMgt = "college" open file DMCFrames.htm
if DebtMgt = "hs" open file DMHSFrames.htm
Get the picture? Each SELECT option has a different Frames files attached.
Again ... THANKS!
Topher
05-25-2004, 10:30 AM
Goldilocks is right, you need the onChange... Change
<SELECT NAME="DebtMgt">
<OPTION VALUE="blank">Select a Time Frame
<OPTION VALUE="hs">High School
<OPTION VALUE="college" onClick="openInfoWindow('DMCFrames.htm');">College
<OPTION VALUE="grace">Grace Period
<OPTION VALUE="Repay">Repayment
<OPTION VALUE="Default">Default
<OPTION VALUE="NA">N/A
</SELECT>
to
<SELECT NAME="DebtMgt" onChange="if (this.value=='college') {openInfoWindow('DMCFrames.htm')};">
<OPTION VALUE="blank">Select a Time Frame
<OPTION VALUE="hs">High School
<OPTION VALUE="college">College
<OPTION VALUE="grace">Grace Period
<OPTION VALUE="Repay">Repayment
<OPTION VALUE="Default">Default
<OPTION VALUE="NA">N/A
</SELECT>
And another thing - I prefer (others may disagree) to use closing </option> tags. Makes it less messy, IMO.
Willy Duitt
05-25-2004, 05:28 PM
Originally posted by Topher
And another thing - I prefer (others may disagree) to use closing </option> tags. Makes it less messy, IMO.
They are required if you ever expect to validate your page.
SpecialK-MI
05-25-2004, 05:32 PM
THANKS everyone!!!!! With your help, problem solved.
vBulletin® v3.6.7, Copyright ©2000-2010, Jelsoft Enterprises Ltd.