Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

document.getElementById problem - ok in firefox not in ie6

Posted on 2006-11-24
7
Medium Priority
?
1,477 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 2000 total points
ID: 18006674
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
ID: 18006831
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
ID: 18006921
it's not enough information, send whole the code please.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Author Comment

by:scathe
ID: 18007196
thanks alain34  thats exactly what it was
0
 
LVL 1

Author Comment

by:scathe
ID: 18007205
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
ID: 18007206
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
ID: 18007323
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
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…
Suggested Courses

971 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