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

onChange() bug?

Status
Not open for further replies.

birney29

Programmer
Oct 11, 2001
140
0
0
GB
hi,

I have a function that can be called fine from the onLoad() event, but if i try to call it from an onChange() event, it doesnt work, giving a "object doesnt support this property or method) error. for example,

function StatusReason()
{
alert("function called");
if (document.CertificateForm.Status.options[document.CertificateForm.Status.selectedIndex].text == "Cancelled")
{
fillReasonStatusCancelledSelect();
}
if (document.CertificateForm.Status.options[document.CertificateForm.Status.selectedIndex].text == "Change Of Address")
{
fillReasonStatusChangeOfAddressSelect();
}
if (document.CertificateForm.Status.options[document.CertificateForm.Status.selectedIndex].text == "Duplicate/Replacement")
{
fillReasonStatusDuplicateSelect();
}
if (document.CertificateForm.Status.options[document.CertificateForm.Status.selectedIndex].text == "Partially Revoked")
{
fillReasonStatusPartiallyRevokedSelect();
}
if (document.CertificateForm.Status.options[document.CertificateForm.Status.selectedIndex].text == "Revoked")
{
fillReasonStatusRevokedSelect();
}
if (document.CertificateForm.Status.options[document.CertificateForm.Status.selectedIndex].text == "Transferred Out")
{
fillReasonStatusTransferredOutSelect();
}



}


<body bgcolor = &quot;#999999&quot; text = &quot;#000000&quot; class = &quot;banner&quot; onLoad = &quot; fillDropDowns();enable();setForCancel();StatusReason();&quot;>

<input type=&quot;select&quot; onChange=&quot;StatusReason();&quot;/>

I have the same code on other screens and it works fine. any ideas? i use ie6

Thank you
Kenneth Birney
User Interface Programmer
Scottish Police
 
There's no such thing as <input type=&quot;select&quot;>.
It's just:
<select name=&quot;Status&quot; onChange=&quot;StatusReason();&quot; />
<option>
...
</select>

Also, I'd recommend you to improve your script code to make it shorter and more readable:

function StatusReason()
{
obj = document.CertificateForm.Status;

alert(&quot;function called&quot;);
if (obj.options[obj.selectedIndex].text == &quot;Cancelled&quot;)
{
fillReasonStatusCancelledSelect();
}
if (obj.options[obj.selectedIndex].text == &quot;Change Of Address&quot;)
. . .

 
yeah, sorry bout the input thing. just typing up an example. the actual code for the control is

<xsl:element name=&quot;Select&quot;>
<xsl:attribute name=&quot;name&quot;>Status</xsl:attribute>
<xsl:attribute name=&quot;size&quot;>1</xsl:attribute>
<xsl:attribute name=&quot;id&quot;>Status</xsl:attribute>
<xsl:attribute name = &quot;onChange&quot;>disable();changeTextColor(&quot;Status&quot;);StatusReason();</xsl:attribute>
</xsl:element>
Kenneth Birney
User Interface Programmer
Scottish Police
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top