PDA

View Full Version : Javascript to make prompt visible


trickydicky
02-14-2010, 11:46 AM
im not 100% sure if this is the right place to post this, so apologies if not..

I have a modal popup which im using to insert a row into a table asynchronously. I have a button that fires off the INSERT statement. The difficulty im having is that once ive done the aysnch call i want the popup to remain visible but it disappears automatically. Has anyone come across this or have any idea how i can force the popup to remain displayed?? My codes below..


function AddRow() {
var NewRowVar = document.getElementById('NewRowValue').value;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
var queryString = "?row=" + NewRowVar;
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4)
{document.getElementById('TextAreaDIV').innerHTML=xmlhttp.responseText}
}
xmlhttp.open("GET","Includes/newRow.php" + queryString,false);
xmlhttp.send(null);
var promptvar = document.getElementById("AddPROMPT");
promptvar.style.display = "block";
}

I figured that last two lines at the end would force the prompt to be visible buts its like the whole page is refreshing or something. Any ideas? Im stumped!

trickydicky
02-20-2010, 01:42 PM
I managed to figure this out in the end, so if anyone else has this problem i found that adding a few extra commands on the onlclick event does exactly what i needed..

Code i ended up using is below..


onclick="AddRow();document.getElementById('AddRowPROMPT').style.display='block';return false;"

glenngv
02-25-2010, 01:19 AM
This is because you were using a submit button and putting return false in the onclick handler cancels the default action of the submit button.