IE / Firefox Ajax issues
Hi I have an ajax script that validates user information placed in text fields. This works fine in Internet Explorer, but in FireFox I get an error getting gender from list. I have a floor to be placed in a hidden textbox for easier handling. The error I am getting in FF is
dd is null [Break this error] theindex = dd.options [dd.selectedIndex] .value;
My function in javascript is below, this is loaded on body load or after changing the selected gender,
get_gender () function {
{
var dd = document.getElementById("gender_select");
theindex = dd.options[dd.selectedIndex].value;
thevalue = dd.options[dd.selectedIndex].text;
}
document.getElementById("gender_text").value = thevalue;
}
Another problem I ran into was disallowing the div field, this works fine in any other browser but not IE. It should only show the div field after the error is given, but IE always shows the div field.
I am using this line for this: document.getElementById ("username_div"). style.visibility = "hidden";
Instead of pasting all my code, the current page can be viewed at
http://elliottstocks.com/assignment/sign_up/ Ignore the login box, this works great.
Any comments / help would be appreciated. Thanks alot =)
a source to share
To change the zero error:
<select onchange="get_gender()" name="gender_select">
to
<select onchange="get_gender()" name="gender_select" id="gender_select">
document.getElementById
looks for an element in the DOM that has the given attribute id
. The reason it works in IE is because it allows you to select an attribute name
.
a source to share