Solved

document.getElementById problem - ok in firefox not in ie6

Posted on 2006-11-24
7
1,464 Views
Last Modified: 2008-01-09
am using this function to query a database - and it works fine in Firefox - it does not work in IE6.

when the function is called ALL vars in the alert display fine in firefox but
in IE acc_lev and acc_man do not have values.

acc_lev is a parameter passed in of course and acc_man is the id of a SELECT.

whats going on ?

 I've truncated the function to keep it simple:

function sndReqMain(action,acc_lev,id) {
    var email =  document.getElementById("email").value;
    var acc_man = document.getElementById("acc_man").value;
    var year = document.getElementById("year").value;
    var period = document.getElementById("period").value;
    var curr = document.getElementById("currency").value;
    var pro_d = document.getElementById("pro_d").value;
    alert(''email=''+email +'' acc_lev='' + acc_lev + '' acc_man=''+acc_man +'' curr-year-period='' +curr + year + period + '' pro_d=''+pro_d);
0
Comment
Question by:scathe
7 Comments
 
LVL 16

Accepted Solution

by:
alain34 earned 500 total points
Comment Utility
make sure that the id of the field is different than the name of the field. same thing with the javascript variable. It should be different.

IE can be confused if the same word is used. Firefox is not....
0
 
LVL 3

Expert Comment

by:viveksg
Comment Utility
I dont think putting same id and name to a field causes any problems as getElementById only looks for id's and not name's.
It may be the problem with the ID's. Check the spellings once again.
0
 
LVL 3

Expert Comment

by:Masoudgh
Comment Utility
it's not enough information, send whole the code please.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Author Comment

by:scathe
Comment Utility
thanks alain34  thats exactly what it was
0
 
LVL 1

Author Comment

by:scathe
Comment Utility
vivek :  IE uses names if it cant find ids when you use getElementById and clearly doesnt work at all when you use both :)
0
 
LVL 16

Expert Comment

by:alain34
Comment Utility
sorry viveksg, I experience the issue first hand.
Thank you microsoft. By the way, scathe could you tell us which version of IE you are using. I was hoping that this issue was resolved within IE7...
0
 
LVL 1

Author Comment

by:scathe
Comment Utility
ie v6.0.2900

didnt try it in ie7

so, yes this problem was ie refusing to read the value based on the id of a SELECTif the name attribute was the same name

another interesting feature is Firefox will return the TEXT of an option if you do not have a VALUE for it, but IE will return NULL - which i suppose is correct in that case :)

thanks all who replied
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now