weixin_33738578 2009-05-21 15:05 采纳率: 0%
浏览 40

IE / Firefox中的Ajax问题

Hi I have an ajax script which validates the users information put into textboxes. This is working fine in Internet Explorer, but in FireFox I get an error in getting the gender from a listbox. I have got the gender to be placed into a hidden textbox, for easier processing. The error I get in FF is

dd is null [Break on this error] theindex = dd.options[dd.selectedIndex].value;

My function in javascript is below, this is loaded on body load or once the gender selected is changed,

function get_gender() {
{

    var dd = document.getElementById("gender_select");
    theindex = dd.options[dd.selectedIndex].value;
    thevalue = dd.options[dd.selectedIndex].text;
    }

    document.getElementById("gender_text").value = thevalue;    

}  

One other problem I am having is hidding a div box, this works fine in every other browser but not IE. It should only show the div box once an error is given, but in IE the div box is always shown.

I am using this line to do this: document.getElementById("username_div").style.visibility = "hidden";

Rather than pasting all my code the live page can be viewed at

http://elliottstocks.com/assignment/sign_up/ Ignore the login box, this works fine.

Any comments/help will be appreciated. Thanks alot =)

  • 写回答

3条回答 默认 最新

  • Memor.の 2009-05-21 15:08
    关注

    For the null error change:

    <select onchange="get_gender()" name="gender_select">
    

    to

    <select onchange="get_gender()" name="gender_select" id="gender_select">
    

    document.getElementById is looking for an element in the DOM that has a given id attribute. The reason it works in IE is because it allows selecting by name attribute as well.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据