Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript within PHP 1

Status
Not open for further replies.
you just draw it to the screen like you do any other html. what are you trying to call?

___________________________________
[morse]--... ...--[/morse], Eric.
 
You cannot "call" a JavaScript function with PHP. All you can do is output code that is interpreted by the browser once the web server has delivered the PHP generated output.
Don't forget:
PHP is server side, JavaScript client side.
If you are asking how to trigger the JavaScript function when the page is loaded in the browser the JavaScript forum might be a better place to ask.
 
Easy answer: No, not with PHP.
Better answer:
You can use JavaScript to open it with the submission. Attach a onSubmit() event to the form (in the form tag). That should be doing what you want.
 
Right. Which brings me back to my original question. I probably shouldn't have used the term 'call'. Sorry. I'm using the onsubmit() and its not working. The example I found in the javascript section of your forums is:

<form name="whatever" action="blah.php" onsubmit="return checkForm();">

<input type="text" name="test">
<input type="submit" value="submit form">
</form>

<script language="javascript">
function checkForm()
{ var bRet;
oFrm = document.forms["whatever"];
if (oFrm.test.value== "")
{ alert("Please enter some text");
bRet = false;
}
else
{ oWin = window.open("", "windowName", "height=200,width=400,toolbar=1" );
oFrm.target="windowName";
bRet = true;
}

return bRet;
}
</script>

The little ! icon in the status bar shows there is an error. Otherwise, it is just ignored and the action page opens in the same window, not a new one.


~ bruwmac ~
 
Here's my advice for the (!) scenario:
Download Mozilla Firefox. IE has no useful JavaScript debugging tools.
In Firefox (or Mozilla) in the Tools click on JavaScript console. It will tell you what kind of error it is.
 
u get a star for that, firefox is cool
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top