PDA

View Full Version : Passsing a value to a Javascript AJAX popup



welsh_boy01
Sep 7th, 2007, 01:39 PM
Hi guys, I am trying to re-write my previous 5 page tool to maintain a basic HTML table into a single page with different AJAX popups.

I have managed to code one of the AJAX boxes "add record" as this didn't require any variables to be passed via the URL.

The other methods such as "delete record" all previously worked via delete.php?id=10 URL and code in the delete.php referencing $id;

My code now uses the following method


<!-- AJAX -->

<style type='text/css'>
.dragme { cursor: move }
</style>
<script type='text/javascript'>
var ie = document.all;
var nn6 = document.getElementById &&! document.all;

var isdrag = false;
var x, y;
var dobj;

function movemouse( e ) {
if( isdrag ) {
dobj.style.left = nn6 ? tx + e.clientX - x : tx + event.clientX - x;
dobj.style.top = nn6 ? ty + e.clientY - y : ty + event.clientY - y;
return false;
}
}



function selectmouse( e ) {
var fobj = nn6 ? e.target : event.srcElement;
var topelement = nn6 ? "HTML" : "BODY";

while (fobj.tagName != topelement && fobj.className != "dragme") {
fobj = nn6 ? fobj.parentNode : fobj.parentElement;
}

if (fobj.className=="dragme") {
isdrag = true;
dobj = document.getElementById("styled_popup");
tx = parseInt(dobj.style.left+0);
ty = parseInt(dobj.style.top+0);
x = nn6 ? e.clientX : event.clientX;
y = nn6 ? e.clientY : event.clientY;
document.onmousemove=movemouse;
return false;
}
}



function styledPopupClose() {
document.getElementById("styled_popup").style.display = "none";
}

function updatePopupClose() {
document.getElementById("update_popup").style.display = "none";
}

document.onmousedown=selectmouse;
document.onmouseup=new Function("isdrag=false");
</script>


<!-- END AJAX -->

The popups are coded within <div> tags and appear fine, but I am lost as to how to pass variables and process them within these AJAX popups.

The popups are invoked via

<input type='submit' onClick='document.getElementById("styled_popup").style.display="block"' value='Add record'>

If you could let me know how to pass variables to the <div> popups that would be great :)

welsh_boy01
Sep 7th, 2007, 02:27 PM
Sorry this is a DHTML popup, not AJAX