I have a link called "Save" on a page of mine, which, when clicked on (the url is typically like this)
, 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:
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.leng th' 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.
Can someone kindly help? Thank you for your time!
Code:
javascript:savesubmit('form31','results31','1','movies','178')
This is the JavaScript function savesubmit:
Code:
function savesubmit(formname, loc, noofvenues, which, mapid) { var f = document.forms[formname]; alert(f);//this alert was to test if the form name was coming in properly var params = ""; for (i=0;i < (f.elements.length);i++) { params = params + f.elements[i].name +'='+ encodeURI(f.elements[i].value) + '&'; } shows = loc; xmlHttp=GetXmlHttpObject(); if (xmlHttp==null) { alert ("Browser does not support HTTP Request"); return; } var url = 'http://www.mysite.com/section/myspace/save.php/'+which+'/'+f.eventid.value+'/1/'+mapid+'/'+noofvenues var eventid = f.eventid.value; url = url + "?" + params; var update_loc = eventid + 'save'; var update_form = eventid; xmlHttp.onreadystatechange=stateChangedALL; xmlHttp.open("GET",url,true); xmlHttp.send(null); updatesave(update_form, update_loc, noofvenues, which, mapid); }
The problem is, this thing is working in IE but not in FF. When I click on the Save link, it says "'elements.leng th' 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.
Code:
<TD WIDTH="510" BGCOLOR="#FFFFFF" VALIGN="TOP" STYLE='padding-right: 10'> <A HREF="/profile/movies/31"><SPAN CLASS="Basic_LARGE_BLUE_LINK">Cheeni Kum</SPAN></A> <BR> <SPAN CLASS="Basic_LARGE_NORMAL">64-year-old Buddhadeb is single and lives with mom. Now, aren't the possibilities endless?</SPAN> <BR> <BR><A HREF='/profile/locations/178'>PVR Cinema (Punjagutta)</A> (13.3 km) <BR><BR> <DIV id="31save" STYLE="float:left"> <A HREF="/profile/movies/31/1">Rate</A> • <A HREF="javascript:savesubmit('form31','results31','1','movies','178')">Save</A> • <A HREF="/profile/locations/178/4">Map</A> <DIV STYLE="clear:both;"></DIV> </DIV> <FORM NAME="deleteform31" STYLE="margin:0px"> <INPUT TYPE="hidden" NAME="eventid" VALUE="31"> <INPUT TYPE="hidden" NAME="edittype" VALUE="delete"> </FORM> <FORM NAME="form31" STYLE="margin:0px"> <INPUT TYPE="hidden" NAME="eventid" VALUE="31"> <INPUT TYPE="hidden" NAME="edittype" VALUE="update"> </FORM> <DIV STYLE="clear:both"></DIV> <DIV id="results31" ></DIV> </TD>
Comment