Solved

document.getElementById problem - ok in firefox not in ie6

Posted on 2006-11-24
7
1,470 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
arrays and buttons with user input 2 42
Horizontal Full Calendar using php 5 43
Change background images after 5 seconds. 12 47
Jquery syntax 12 30
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…
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…

738 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