^^ Thank you for that. I'll have a look at it.
Lionel, I just downloaded your script. Thanks for the credit.
I saw you modified it a bit... don't use getElementById, cause it's not cross browser safe. Use vB's fetch_object() function instead.
Code:
fetch_object('button'+ form.eventid.value).innerHTML = '<a href="predictions.php?do=remove&eventid='+ form.eventid.value +'">Remove</a>';
Also, I'll have a look on how to make it compatible with vB's AJAX system and post an updated version later.
EDIT:
Give this a try.
Code:
function submit_form(form)
{
if (isNaN(form.Home.value) || isNaN(form.Away.value) || !form.Home.value || !form.Away.value)
{
alert("Invalid prediction. Please use numbers only.");
return false;
}
http = new vB_AJAX_Handler(true);
if (!http)
{
return true;
}
http.onreadystatechange(handle_prediction);
http.send('predictions.php', 'do=addpredict&Home='+ form.Home.value +'&Away='+ form.Away.value +'&eventid='+ form.eventid.value +'&1Home='+ form.Home1.value +'&1Away='+ form.Away1.value);
return false;
}
function handle_prediction()
{
if (http.handler.readyState == 4 && http.handler.status == 200)
{
var form = document.predictions;
fetch_object('Home'+ form.eventid.value).innerHTML = form.Home.value;
fetch_object('Away'+ form.eventid.value).innerHTML = form.Away.value;
fetch_object('button'+ form.eventid.value).innerHTML = '<a href="predictions.php?do=remove&eventid='+ form.eventid.value +'">Remove</a>'
}
}
You have to change the form name to "predictions", or change predictions to something else in the second function.