There were a couple of syntax errors. Also note that variable names cannot begin with numbers. Neither in PHP nor Javascript. (I changed
1Home to
Home1 and
1Away to
Away1).
This works for me.
Code:
<script type="text/javascript">
function create_req_object()
{
var req = false;
if (window.XMLHttpRequest)
{
req = new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
var msp = new Array('Microsoft', 'Msxml2');
for (var i in msp)
{
try
{
req = eval('ne' + 'w Act' + 'iveXObj'+ 'ect(msp[i] + ".XMLH'+ 'TTP");');
}
catch(e)
{
continue;
}
}
}
return req;
}
function submit_form(form)
{
var http = create_req_object();
if (!http)
{
return true;
}
http.open('POST', form.action);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.onreadystatechange = function()
{
if (http.readyState == 4 && http.status == 200)
{
alert("The data has been submitted.");
}
}
http.send('do=addpredict&Home='+ form.Home.value +'&Away='+ form.Away.value +'&eventid='+ form.eventid.value +'&1Home='+ form.Home1.value +'&1Away='+ form.Away1.value);
return false;
}
</script>
<form action="predictions.php" method="post" onsubmit="return submit_form(this);">
<input type="hidden" name="do" value="addpredict">
<input type="hidden" name="eventid" value="32">
<table class="tborder" cellspacing="1" cellpadding="4" border="0">
<tr><td class="tcat" colspan="5">Interactive game details</td></tr>
<tr><td class="thead">Your predictions</td><td class="thead">Actual</td><td colspan="2" align="center" class="thead">Teams</td><td class="thead">Colors</td></tr>
<div class="smallfont">
<tr><td align="center">
<input type="hidden" name="Home1" value="RDG">
<input name="Home" type="text" size="1" value="">
</td><td class="alt2" align="center"></td><td nowrap>
<strong>Home</strong>:
</td><td>
RDG
</td><td><img src="images/calendarteams/RDG.gif">
</div>
</td></tr>
<div class="smallfont">
<tr><td align="center">
<input type="hidden" name="Away1" value="Victory">
<input name="Away" type="text" size="1" value="">
</td><td class="alt2" align="center"></td><td nowrap>
<strong>Away</strong>:
</td><td>
Victory
</td><td><img src="images/calendarteams/Victory.gif">
</div>
</td></tr>
<div class="smallfont">
<strong>Venue</strong>:
Gonaives - Parc Vincent
</div>
<div class="smallfont">
<strong>Competition</strong>:
Digicel Cloture
</div>
<div class="smallfont">
<strong>Round</strong>:
9
</div>
<tr><td align="center"><input type="image" src="/forums/images/kirsch/buttons/predict.gif"></td><td">/buttons/predict.gif"></td><td class="alt2" style="border-top:0px solid #c0c0c0;" align="center" colspan="4">insert link to leaderboard here</td></tr>
</table>
</form>