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

works in firebox and netscape but in IE get object expected 1

Status
Not open for further replies.

mcghee31

IS-IT--Management
Dec 13, 2007
12
US
I have a basic script that disable and enables twp input text boxes. It works in Firefox and Netscape but on in Internet Explorer 6

I call the external script in the html head using:

<script type="text/javascript" src="./include/enable_disable.js"></script>

I call the function using the onclick using:

<div class="new">
<label for="new">New</label>
<input type="checkbox" name="enable_disable" value="new" id="new" onclick="codename()" />
</div>


so basically onclick will call the js function codename().
I know it must be a sytax issue that is needed in IE6 that is not needed for firefox or netscape but I have no idea.

newbie seeking help


javascript code




function codename()
{

if(document.appts.new.checked)
{
document.appts.req_f_name.disabled=false;
document.appts.req_l_name.disabled=false;
}

else
{
document.appts.req_f_name.disabled=true;
document.appts.req_l_name.disabled=true;
}

}
 
Try this as a replacement function:

Code:
function codename() {
	var frm = document.forms['appts'].elements;

	if (frm['enable_disable'].checked) {
		frm['req_f_name'].disabled = false;
		frm['req_l_name'].disabled = false;
	} else {
		frm['req_f_name'].disabled = true;
		frm['req_l_name'].disabled = true;
	}
}

You were referring to "new" which was an ID, and I think that IE might count that as a reserved word.

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top