Solved

document.getElementById problem - ok in firefox not in ie6

Posted on 2006-11-24
7
1,474 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article discusses how to create an extensible mechanism for linked drop downs.
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

617 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