[JavaScript] 405 error with StaticFile handler due to changing font color
1 replies, posted
Using IIS on my desktop to test things, and for whatever reason this one line of code is causing a 405 error when it really shouldn't be, its javascript so yay
the HTML portion:
[code]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<noscript>
<meta http-equiv="refresh" content="0;href=noscript.html">
</noscript>
<title>Untitled Document</title>
<script type="text/javascript" src="core.js"></script>
</head>
<body>
<h2>Please enter your mailing address.</h2>
<form name="mailingAddressForm" method="POST" onsubmit="return validateForm();" >
<table width="98%" border="0">
<tr>
<td> </td>
<td><div align="right"><label for="nameTextBox">Name</label><font size="3" color="red">*</font>:</div></td>
<td>
<input required type="text" name="nameTextBox" id="nameTextBox" tabindex="1" /></td>
</tr>
<tr>
<td width="2%"> </td>
<td width="12%"><div align="right"><label for="countryListBox">Country<font size=3 color=red>*</font>:</label></div></td>
<td width="86%">
<select name="countryListBox" id="countryListBox" tabindex="2" onchange="stateProvinceSwitch(this);">
<option value="none" selected>Select a Country</option>
<option value="0">United States</option>
<option value="1">Canada</option>
</select></td>
</tr>
<tr>
<td> </td>
<td><div align="right">
<label for="regionListBox">State/Province<font size=3 color=red>*</font>:</label></div></td>
<td>
<select name="regionListBox" id="regionListBox" tabindex="3">
<option value="none">Select a Country</option>
</select></td>
</tr>
<tr>
<td> </td>
<td><div align="right"><label for="cityTextBox">City<font size=3 color=red>*</font>:</label></div></td>
<td>
<input required type="text" name="cityTextBox" id="cityTextBox" tabindex="4" /></td>
</tr>
<tr>
<td> </td>
<td><div align="right"><label for="mailCodeTextBox">Postal/Zip Code<font size=3 color=red>*</font>:</label></div></td>
<td>
<input required type="text" name="mailCodeTextBox" id="mailCodeTextBox" tabindex="5" onchange="validatePoseCode(this.text);"/></td>
</tr>
<tr>
<td> </td>
<td><div align="right">
<label for="addressLine1TextBox">Address Line 1<font size=3 color=red>*</font>:</label></div></td>
<td>
<input type="text" name="addressLine1TextBox" id="addressLine1TextBox" tabindex="6" /></td>
</tr>
<tr>
<td> </td>
<td><div align="right">Address Line 2:</div></td>
<td>
<input type="text" name="addressLine2TextBox" id="addressLine2TextBox" tabindex="7" /></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="submitButton" id="submitButton" value="Submit" tabindex="8" /></td>
</tr>
</table>
</form>
<h6>
<p><font size=3 color=red>*</font> Indicates required field.
</p>
<p> </p>
<table id="postLabel" width="200" border="0" hidden>
<tr>
<td><span id="labelName" color="black"> </span></td>
</tr>
<tr>
<td><span id="labelAddrLine1" color="black"> </span></td>
</tr>
<tr>
<td><span id="labelAddrLine2" color="black"> </span></td>
</tr>
<tr>
<td><span id="labelRegion" color="black"> </span></td>
</tr>
<tr>
<td><span id="labelCountry" color="black"> </span></td>
</tr>
<tr>
<td><span id="labelStars" color="black"> </span></td>
</tr>
</table>
<p> </p>
</body>
</html>
[/code]
and the javascript portion
[code]
// JavaScript Document
var stateArray = ["Alabama","Alaska","Arizona","Arkansas","California","Colorado","Connecticut","Delawate","Florida","Georgia","Hawaii","Idaho","Indiana","Iowa","Kansas","Kentucky","Louisiana","Maine","Maryland","Massachusetts","Michigan","Minnesota","Mississippi","Missouri","Montana","Nebraska","Nevada","New Hampshire","New Jersy","New Mexico","New York","North Carolina","North Dakota","Ohio","Oklahoma","Oregon","Pennsylvania","Rhode Island","South Carolina","South Dakota","Tennessee","Texas","Utah","Vermont","Virginia","Washington","West Virginia","Wisconsin","Wyoming","District of Columbia"];
var stateAbvrArray = ["AL","AK","AZ","AR","CA","CO","CT","DE","FL","GA","HI","ID","IL","IN","IA","KS","KY","LA","ME","MD","MA","MI","MN","MS","MO","MT","NE","NV","NH","NJ","NM","NY","NC","ND","OH","OK","OR","PA","RI","SC","SD","TN","TX","UT","VT","VA","WA","WV","WI","WY","DC"];
var provinceAbvrArray = ["AB","BC","MB","NB","NL","NT","NS","NU","ON","PE","QC","SK","YT"];
var provinceArray = ["Alberta","British Columbia","Manitoba","New Brunswick","Newfoundland and Labrador","Northwest Territories","Nova Scotia","Nunavut","Ontario","Prince Edward Island","Quebec","Saskatchewan","Yukon"];
function stateProvinceSwitch(country)
{
var teritoryBox = document.mailingAddressForm.regionListBox;
//var teritoryBox = document.getElementById("regionListBox");
teritoryBox.options.length = 0;
if(country.value == 0)
{
teritoryBox.options[teritoryBox.options.length] = new Option("Select a State","none");
for(var i=0;i<stateArray.length;i++)
{
teritoryBox.options[teritoryBox.options.length] = new Option(stateArray[i],i);
}
}
else if(country.value == 1)
{
teritoryBox.options[teritoryBox.options.length] = new Option("Select a Province","none");
for(var i=0;i<provinceArray.length;i++)
{
teritoryBox.options[teritoryBox.options.length] = new Option(provinceArray[i],i);
}
}
else
{
teritoryBox.options[teritoryBox.options.length] = new Option("Select a Country","none");
}
}
function validateForm()
{
var zipFinder = new RegExp("^\\d{5}(-\\d{4})?$");
var postalFinder = new RegExp(/^[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJKLMNPRSTVWXYZ]( )?\d[ABCEGHJKLMNPRSTVWXYZ]\d$/i);
var form = document.mailingAddressForm;
if(form.countryListBox.value == "none")
{
alert("Please Select a Country")
return false;
}
else if(form.regionListBox.value == "none")
{
var tmpText;
var country =form.countryListBox.value;
if(country == 0)
{
tmpText = "State";
}
else if(country == 1)
{
tmpText = "Province";
}
else
{
tmpText = "State/Province";
}
alert("Please Select a " + tmpText+".");
return false;
}
else if((zipFinder.test(form.mailCodeTextBox.value) == false) && (form.countryListBox.value == 0))
{
alert("Please enter a valid ZIP code.");
return false;
}
else if((!postalFinder.test(form.mailCodeTextBox.value)) && (form.countryListBox.value == 1))
{
alert("Please enter a valid postal code.");
return false;
}
else
{
if(form.countryListBox.value==0)
{
var regionLine = form.cityTextBox.value+", "+ stateAbvrArray[form.regionListBox.value] +" " + form.mailCodeTextBox.value;
}
else
{
var regionLine = form.cityTextBox.value+", "+ provinceAbvrArray[form.regionListBox.value] +" " + form.mailCodeTextBox.value;
}
var manyStars = "";
var textColour;
if(form.countryListBox.value == 0)
{
textColour="#0000FF";
}
else if(form.countryListBox.value == 1)
{
textColour="#FF0000";
}
else
{
textColour="#000000";
}
for(var i = 0;i<countryListBox.options[form.countryListBox.selectedIndex].innerHTML.length;i++)
{
manyStars = manyStars +"*";
}
document.getElementById("labelName").style.color=textColor;
document.getElementById("labelName").innerHTML=form.nameTextBox.value;
document.getElementById("labelAddrLine1").style.color=textColor;
document.getElementById("labelAddrLine1").innerHTML=form.addressLine1TextBox.value;
document.getElementById("labelAddrLine2").style.color=textColor;
document.getElementById("labelAddrLine2").innerHTML=form.addressLine2TextBox.value;
document.getElementById("labelRegion").style.color=textColor;
document.getElementById("labelRegion").innerHTML=regionLine;
document.getElementById("labelCountry").style.color=textColor;
document.getElementById("labelCountry").innerHTML=form.countryListBox.options[form.countryListBox.selectedIndex].innerHTML;
document.getElementById("labelStars").style.color=textColor;
document.getElementById("labelStars").innerHTML=manyStars;
document.getElementById("postLabel").hidden = false;
return false;
}
}
[/code]
I know what lines of code are causing it too, lines 113, 116 119, 122, 125 and 128, for some reason I cant change the color of any text, and I've used both style.color, tried putting in font tags into the string I put into the span, I've tried everything that can change text color and nothing happens
and yes I believe IIS is properly configured, StaticFile is allowed to use all verbs,
Can anyone help me out with this its driving me nuts
The variable is called textColour but you use textColor at the style parts.
document.getElementById("labelName").style.color=textColor; <-- textColor
textColour="#000000"; <-- textColour
Sorry, you need to Log In to post a reply to this thread.