Solved

document.getElementById problem - ok in firefox not in ie6

Posted on 2006-11-24
7
1,468 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
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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
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…

770 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