/    Sign up×
Community /Pin to ProfileBookmark

Script works in IE but not in Fire Fox

Cand somebody look at my script (bellow) and tell me what I need to change/add so it works in both IE and Firefox. Right now it works without a problem in IE but in Firefox the variable postStr remains undefined. You will see in my code I do an alert of postStr where it tells me undefined. Any assistance would be appreciated.

[CODE]
function QuotePage()
{
if (document.getElementById(“frmSignIn”))//Sign In Form
{
var postStr=”txtEmail=” + encodeURI(document.getElementById(“txtEmail”).value) + “&txtPassword=” + encodeURI(document.getElementById(“txtPassword”).value);
var url = “quote.php”;
}
else //Quote Page
{
if(document.getElementById(“txtContact”)) //Existing Customer
{
var postStr=”txtRequestDate=” + encodeURI(document.getElementById(“txtRequestDate”).value) + “txtCustomerID=” + encodeURI(document.getElementById(“txtCustomerID”).value) + “txtContact=” + encodeURI(document.getElementById(“txtContact”).value) + “txtBusinessName=” + encodeURI(document.getElementById(“txtBusinessName”).value) + “txtBillingAddress=” + encodeURI(document.getElementById(“txtBillingAddress”).value) + “txtShippingAddress=” + encodeURI(document.getElementById(“txtShippingAddress”).value) + “txtQuoteRequest=” + encodeURI(document.getElementById(“txtQuoteRequest”).value) + “txtEmail=” + encodeURI(document.getElementById(“txtEmail”).value) + “txtPassword=” + encodeURI(document.getElementById(“txtPassword”).value);
}
else //New Customer
{
}
var url = “quote_complete.php”;
}
if (window.XMLHttpRequest)
{
xhr = new XMLHttpRequest();
}
else
{
if (window.ActiveXObject)
{
try
{
xhr = new ActiveXObject(“Microsoft.XMLHTTP”);
}
catch (e){}
}
}
if (xhr)
{
alert(postStr);
xhr.onreadystatechange = showContents;
xhr.open(“POST”, url, true);
xhr.setRequestHeader(“Content-type”, “application/x-www-form-urlencoded”);
xhr.setRequestHeader(“Content-length”, postStr.length);
xhr.setRequestHeader(“Connection”, “close”);
xhr.send(postStr);
}
else
{
alert(“Sorry, but I couldn’t create an XMLHttpRequest”);
}
}
[/CODE]

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@Four_StaplesJun 08.2009 — Seems to indicate that neither lines 3 or 10 are returning true. Can you post your HTML?
Copy linkTweet thisAlerts:
@Sterling_IsfineJun 08.2009 — "txtEmail", "txtRequestDate" - are these IDs or names?
Copy linkTweet thisAlerts:
@cyberjudgeauthorJun 08.2009 — Here is my quote.php page that calles the script above. This is only a small clip of the code. The whole page actually has 2 forms, one for a login screen (included here) and the other to display after login is completed successfully. Right now it is this code that I'm trying to get working with my script above.

[CODE]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Genesis Technology - Quote Request</title><?php
if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'gecko')!== false)
{
echo "<LINK REL="stylesheet" TYPE="text/css" HREF="scripts/mozlayout.css">";
}
else
{
echo "<LINK REL="stylesheet" TYPE="text/css" HREF="scripts/ielayout.css">";

}?>
<script language="javascript" type="text/javascript" src="scripts/formscripts.js"></script>
<script language="javascript" type="text/javascript" src="scripts/ajax.js"></script>
</head>
<body class="bodymain">
<table class="tablePL">
<tr>
<td class="tdTitle">
<img src="images/Quote_Title.jpg">

</td>
</tr>
</table>

<?PHP
if (!isset($_POST['txtEmail']) and !isset($_POST['txtPassword'])) //Nothing has been specifified for email and password.
{?>
<form name="frmSignIn" method="post" action="quote.php">
<table class="tablePL">
<tr>
<td class="tdNormal" colspan="2">
With all the different options when it comes to web design and computer service Genesis Technology prefers to customize a package that is right for you. Please complete the following form and a member of our team will get back to you with a quote.
Thank-You for your interest in Genesis Technology.
</td>
</tr>
<tr>
<td class="tdNormal" style="font-weight:bold; vertical-align:top;">
Return Customer:
</td>
<td class="tdNormal">
Please put in the email address and password you setup previously.
</td>
</tr>
<tr>
<td class="tdNormal" style="font-weight:bold; vertical-align:top;">
New Customer:
</td>
<td class="tdNormal">
Specify an email address and password you wish to use and click the "Log In" button to create a new account.
</td>
</tr>

</table>
<table class="tablePL">
<tr>
<th class="setcolor" style="text-align:right;"> Email Address:&nbsp;&nbsp; </th>
<td style="text-align:left;"><input type="text" name="txtEmail" id="txtEmail" size="50" maxlength="150" /></td>
</tr>
<tr>
<th class="setcolor" style="text-align:right;">Password:&nbsp;&nbsp;</th>
<td style="text-align:left;"><input type="password" name="txtPassword" id="txtEmail" size="30" maxlength="12" /></td>
</tr>
<tr>
<td colspan="2" style="text-align:center">
<input type="button" value="Log In" name="cmdLogin" onclick="verifyEmail();" />
</td>
</tr>
</table>
</form><?PHP
}
[/CODE]
Copy linkTweet thisAlerts:
@cyberjudgeauthorJun 08.2009 — "txtEmail", "txtRequestDate" - are these IDs or names?[/QUOTE]

They are both id and name
Copy linkTweet thisAlerts:
@Four_StaplesJun 08.2009 — They are both id and name[/QUOTE]

There is neither a field with id = "txtContact" or a form with id = "frmSignIn". Change your <form> to this:&lt;form name="frmSignIn" [b]id="frmSignIn"[/b] method="post" action="quote.php"&gt;
Copy linkTweet thisAlerts:
@cyberjudgeauthorJun 08.2009 — There is neither a field with id = "txtContact" or a form with id = "frmSignIn". Change your <form> to this:&lt;form name="frmSignIn" [b]id="frmSignIn"[/b] method="post" action="quote.php"&gt;[/QUOTE]

OK, I'll give that a try. As far as txtContact, that is in another section of the page that I did not post here.
×

Success!

Help @cyberjudge spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...