Jump to content

Submit form works in IE - But Not FireFox.


Recommended Posts

<script type="text/javascript">
<!--
var divid = 'output';
var loadingmessage = '<b><font color="RED">Processing...</font></b>';
function AJAX(){
var xmlHttp;
try{
xmlHttp=new XMLHttpRequest(); // Firefox, Opera 8.0+, Safari
return xmlHttp;
}
catch (e){
try{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer
return xmlHttp;
}
catch (e){
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
return xmlHttp;
}
catch (e){
alert("Your browser does not support AJAX!");
return false;
}
}
}
}
function formget(f, url) {
var poststr = getFormValues(f);
postData(url, poststr);
}
function postData(url, parameters){
var xmlHttp = AJAX();
xmlHttp.onreadystatechange =  function(){
if(xmlHttp.readyState > 0 && xmlHttp.readyState < 4){
document.getElementById(divid).innerHTML=loadingmessage;
}
if (xmlHttp.readyState == 4) {

document.getElementById(divid).innerHTML=xmlHttp.responseText;
}
}

xmlHttp.open("POST", url, true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", parameters.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(parameters);
}

function getFormValues(fobj)

{
var str = "";
var valueArr = null;
var val = "";
var cmd = "";

for(var i = 0;i < fobj.elements.length;i++)

{
switch(fobj.elements[i].type)

{

case "select-one":

str += fobj.elements[i].name +
"=" + fobj.elements[i].options[fobj.elements[i].selectedIndex].value + "&amp;";
break;

}
}

str = str.substr(0,(str.length - 1));
return str;

}

//--></script>

 

<script type="text/javascript" language="javascript">
function submitform(){
formget(aForm, 'do.php');
}
</script>

<?
if (!empty($_REQUEST['user'])) {
$user = $_REQUEST['user'];
$user=str_replace("/","",$user);
echo "<body onload='javascript:submitform()'>";
}
?>

 

Basically if 'http://127.0.0.1/go.php?user=jon' then the form should automatically be submitted.

 

If no 'user' variable is set on the url then load the full form..

 

This works in IE, but not in Firefox.. any ideas ??

In Firefox nothing seems to happen !!

 

Thanks :)

Link to comment
https://forums.phpfreaks.com/topic/181736-submit-form-works-in-ie-but-not-firefox/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.