473,386 Members | 1,654 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Javascript code that works in Firefox but not in IE

49
I have a link called "Save" on a page of mine, which, when clicked on (the url is typically like this)
Expand|Select|Wrap|Line Numbers
  1. javascript:savesubmit('form31','results31','1','movies','178')
, calls a javascript function called "savesubmit", which in turn calls a script using AJAX (the script URL is http://www.mysite.com/section/myspace/save.php).

This is the JavaScript function savesubmit:

Expand|Select|Wrap|Line Numbers
  1. function savesubmit(formname, loc, noofvenues, which, mapid)
  2. {
  3.     var f = document.forms[formname];
  4.              alert(f);//this alert was to test if the form name was coming in properly
  5.     var params = "";
  6.     for (i=0;i < (f.elements.length);i++) {
  7.         params = params + f.elements[i].name +'='+ encodeURI(f.elements[i].value) + '&'; 
  8.     }
  9.  
  10.     shows = loc;
  11.     xmlHttp=GetXmlHttpObject();
  12.  
  13.     if (xmlHttp==null)
  14.     {
  15.         alert ("Browser does not support HTTP Request");
  16.         return;
  17.     }
  18.     var url = 'http://www.mysite.com/section/myspace/save.php/'+which+'/'+f.eventid.value+'/1/'+mapid+'/'+noofvenues
  19.     var eventid = f.eventid.value;
  20.     url = url + "?" + params;
  21.     var update_loc = eventid + 'save';
  22.     var update_form = eventid;
  23.     xmlHttp.onreadystatechange=stateChangedALL;
  24.     xmlHttp.open("GET",url,true);
  25.     xmlHttp.send(null);
  26.     updatesave(update_form, update_loc, noofvenues, which, mapid);
  27. }
The form is in a div tag with id 'form31', and the result will be sent to a div tag with id 'results31'.

The problem is, this thing is working in IE but not in FF. When I click on the Save link, it says "'elements.length' is null or not an object". And the alert I put for testing says [object] instead of giving the form name.

Here is the <td> which has the forms etc.

Expand|Select|Wrap|Line Numbers
  1. <TD WIDTH="510" BGCOLOR="#FFFFFF" VALIGN="TOP" STYLE='padding-right: 10'>
  2.     <A HREF="/profile/movies/31"><SPAN CLASS="Basic_LARGE_BLUE_LINK">Cheeni Kum</SPAN></A> 
  3.     <BR>
  4.              <SPAN CLASS="Basic_LARGE_NORMAL">64-year-old Buddhadeb is single and lives with mom. Now, aren't the possibilities endless?</SPAN>
  5.     <BR>
  6.              <BR><A HREF='/profile/locations/178'>PVR Cinema (Punjagutta)</A> (13.3 km)
  7.     <BR><BR>
  8.     <DIV id="31save" STYLE="float:left">
  9.         <A HREF="/profile/movies/31/1">Rate</A> • 
  10.         <A HREF="javascript:savesubmit('form31','results31','1','movies','178')">Save</A> • 
  11.         <A HREF="/profile/locations/178/4">Map</A>                            <DIV STYLE="clear:both;"></DIV>
  12.     </DIV>
  13.  
  14.     <FORM NAME="deleteform31" STYLE="margin:0px">
  15.         <INPUT TYPE="hidden" NAME="eventid" VALUE="31">
  16.         <INPUT TYPE="hidden" NAME="edittype" VALUE="delete">
  17.     </FORM>
  18.     <FORM NAME="form31" STYLE="margin:0px">
  19.         <INPUT TYPE="hidden" NAME="eventid" VALUE="31">
  20.         <INPUT TYPE="hidden" NAME="edittype" VALUE="update">
  21.     </FORM>
  22.     <DIV STYLE="clear:both"></DIV>
  23.     <DIV id="results31" ></DIV>
  24. </TD>
  25.  
Can someone kindly help? Thank you for your time!
Jul 25 '07 #1
3 1343
gits
5,390 Expert Mod 4TB
hi ...

i cannot reproduce the error with your posted code ... it works in a FF 2.0.0.3 and IE 6 here (except of GetXmlHttpObject() since you didn't provide it here of course) ... is your 'test-alert' working correct for you? and what does he say? ...

kind regards
Jul 25 '07 #2
knkk
49
Actually, I figured out the error. The <TD> that I gave there is one of a series of rows, each of which has this link for "Save", calling the JavaScript. So there are several rows, and the first variable of the savesubmit function is a form name, with "form" suffixed by a number which is the ID of the record displayed in that row (e. g. "form31"). This form appears in that <TD> itself, so each <TD> has a form named this way.

There was another row in the same page with the same form name (like "form31"), since that record appeared twice in that page for whatever reason. So when I clicked on that "Save" link, the JS function did not know which form to access. IE just kept saying what I said it did, while FF did not give up - it performed the action on the first form with that name that it encountered.

I wasted your time with a screw-up from my side, I guess :). Thank you again for your time. Cheers!
Jul 26 '07 #3
gits
5,390 Expert Mod 4TB
no problem ... glad to hear you got it working ;) ... come back anytime when you have more questions ...

kind regards
Jul 26 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Howard Kaikow | last post by:
Yesterday, I decided to try Firefox. I've encountered a behavior that is either a bug in Firefox or a bug in my Javascript code. I'll try to explain the problem, hoping that this newsgroup can...
5
by: LRW | last post by:
(Sorry if this is a repost...my newsreader keeps crashing on the posting--I don't know if the message going out or not) For some reason this javascript just won't work in Firefox. It works fine...
8
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
4
by: lmarceglia | last post by:
Hi, I have this website that doesn't work in Firefox 1.5: www.pianetaluca.com The HTML source is: <TITLE>PianetaLuca</TITLE> </HEAD>
11
by: minnesotti | last post by:
Hi there, I subscribed to a photographic pictures-hosting website which is heavy on JavaScript. My preferred latest browser Mozilla Firefox does not work with it -- no pictures are displayed and...
11
by: Joey | last post by:
Hello, In my C# asp.net 2.0 application, I have a webform with a button server control on it. The webform, like most others in the site, subscribes to a master page. I have determined that the...
8
by: Matt Kruse | last post by:
http://news.zdnet.com/2100-1009_22-6121608.html Hackers claim zero-day flaw in Firefox 09 / 30 / 06 | By Joris Evers SAN DIEGO--The open-source Firefox Web browser is critically flawed in...
16
by: Eric | last post by:
I have a user of a web application written in Java/JSP that is unable to login to the site simply because certain links on the page do not run when they are clicked. Other popups using Javascript...
12
by: tim | last post by:
I am using foldoutmenu 3 and am having problems with viewing my menus in firefox. On my sub3 menus i have more than one line of text in some places. firefox does not recognise that there is more...
6
by: davidiwharper | last post by:
Hi there. I'm putting together a page to collect some information from our website users and send the administrator an email. To this end I have some Javascript form validation in an external...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.