|
-
Jan 21st, 2012, 01:02 PM
#1
Thread Starter
Junior Member
Php with Javascript
Hi,
I'm trying to use a JS function within PHP and cant seem to get it to call. Basically, after the users has entered thier details I want a pop up box to appear.
Heres my Code:
<head>
<script type="text/javascript">
<!--
function prompter() {
var reply = prompt("Hey there, good looking stranger! What's your name?", "")
alert ( "Nice to see you around these parts " + reply + "!")
}
//-->
</script>
</head>
<!--
function prompter() {
alert ( "Nice to see you around these parts " + reply + "!")
}
//-->
</head>
<body>
<?php
// Make a MySQL Connection
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("test") or die(mysql_error());
// Insert a row of information into the table "emp"
mysql_query("INSERT INTO test
(Number) VALUES('$_POST[Emp_no]' ) ")
or die(mysql_error());
?>
prompter()
</body>
Any help would be greatly appricated
Twitter @dancematt
Programmers unite
-
Jan 21st, 2012, 01:51 PM
#2
Re: Php with Javascript
The function call is not in proper context (within <script> tags, in this case).
PHP Code:
<?php // Make a MySQL Connection mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("test") or die(mysql_error());
// Insert a row of information into the table "emp" mysql_query("INSERT INTO test (Number) VALUES('$_POST[Emp_no]' ) ") or die(mysql_error()); ?>
<head> <script type="text/javascript"> <!-- function prompter() { var reply = prompt("Hey there, good looking stranger! What's your name?", "") alert ( "Nice to see you around these parts " + reply + "!") } prompter() //--> </script> </head>
<body></body>
-
Jan 21st, 2012, 02:05 PM
#3
Thread Starter
Junior Member
Re: Php with Javascript
Thats worked, thank you kindly for your fast response
Twitter @dancematt
Programmers unite
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|