PDA

View Full Version : Javascript and PHP


smitho
02-19-2008, 10:11 AM
This is more of a javascript problem than PHP so I thought I'd post here. I have some php forms with the data coming from mysql. I have some popups that the user completes and the popups passes the data back the php page.

When the user completes one of the popus I have a hidden field which determines the next step. If the value returned is popup1 then the next popup is popup1.php if the value is popup2 the next popup will be popup2.php.

My questions is can you do somthing like this:

<SCRIPT language="JavaScript">
var popup = document.checklist.publication.value

</SCRIPT>Then where I have the link for the popup have

window.open(<SCRIPT language="JavaScript">popup</SCRIPT>.php...................)Can this be done?

davidj
02-19-2008, 11:46 AM
populate a hidden field with your popup page name driven by your PHP

then access the name using JS .....

/// pagename is the name of your field holding the page ///
fld = document.getElementById('pagename');

/// get the value
page = fld.value;

/// you have the page so use that to launch the popup
window.open(page);


wrap the above in a JS function and complete the window.open method making it valid as i only used pseudo code

smitho
02-19-2008, 11:23 PM
Thanks davidj,

The way I got around this late las night was using this:


<SCRIPT language="JavaScript">
function popup(){
var whichpop = document.form.popup.value;
if(whichpop == "popup1"){
//alert("popup1");
window.open("popup1.php","Ratting","width=400,height=320,left=150,top=200,toolbar=1,st atus=1,");
}else{
//alert("popup2");
window.open("popup2.php","Ratting","width=400,height=320,left=150,top=200,toolbar=1,st atus=1,");
}
}
</SCRIPT>Then where I have the link for the popup I used:

<a href="javascript:void(0);" name="My Window Name" title=" My title here " id="My Window Name2" onclick="popup()">seems to work.