| | |
function in php
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
hi,
this is a simple program it is not working...please do tell me whether my code is correct
this is a simple program it is not working...please do tell me whether my code is correct
PHP Syntax (Toggle Plain Text)
<form> <?php function login() { print "<script>"; print " window.location='http://www.webs.com/hi.html'"; print "</script>"; } print "<input type='button' name='butt' value='Apply Online' onClick=login() style='height :2em; width :7em; font-weight:bold; font-size:0.7em' >"; ?> </form>
•
•
Join Date: Nov 2007
Posts: 86
Reputation:
Solved Threads: 6
you can't call a php function with an onClick event.. onClick is a javascript/DHTML item.
You also don't even need any of the php opening and closing stuff.
Why cause php to print javascript and html items if you already have form tags outside of the scope of the php?
Should do the trick.
Although, you really don't even need any of that stuff.
You are just wanting people to go to another page to fill out an application.
This is easily done in html
Sage
You also don't even need any of the php opening and closing stuff.
Why cause php to print javascript and html items if you already have form tags outside of the scope of the php?
PHP Syntax (Toggle Plain Text)
<script> function login(){ window.location='http://www.webs.com/hi.html'; } </script> <form> <input type='button' name='butt' value='Apply Online' onClick='login();' style='height :2em; width :7em; font-weight:bold; font-size:0.7em' > </form>
Should do the trick.
Although, you really don't even need any of that stuff.
You are just wanting people to go to another page to fill out an application.
This is easily done in html
PHP Syntax (Toggle Plain Text)
<a href="http://www.webs.com/hi.html"><img src="button.gif" /></a>
Sage
•
•
Join Date: Nov 2007
Posts: 86
Reputation:
Solved Threads: 6
ok, you still can't call a php function on a javascript event, which is what your code is trying to do.
What you need to do is use your php to print out the html code but make the onclick event itself the value.
Something like this.
Obviosly you will replace user and registered with whatever you use to check users registration...
What you need to do is use your php to print out the html code but make the onclick event itself the value.
Something like this.
PHP Syntax (Toggle Plain Text)
<?PHP if ($user == $registered){ $onclick = "window.location='http://www.webs.com/page1.html'"; } else { $onclick = "window.location='http://www.webs.com/page2.html'"; } ?> </script> <form> <input type='button' name='butt' value='Apply Online' onClick=' <?php echo $onclick; ?> ' style='height :2em; width :7em; font-weight:bold; font-size:0.7em' > </form>
![]() |
Similar Threads
- how can i make php alert pop ups just like in javascript. (PHP)
- PHP 2 MsSQL (PHP)
- Enabling MSSQL Function in the PHP.ini (PHP)
- Function variables (PHP)
- storing details as html doc using php (PHP)
- PHP Includes + (PHP)
- Function Problem. Please help (PHP)
- php.ini file not being read (PHP)
- Roating testimonials (text) in PHP (PHP)
Other Threads in the PHP Forum
- Previous Thread: using statements in user defined functions
- Next Thread: Is it possible to import profile details from Myspace.com?
| Thread Tools | Search this Thread |
action address ajax apache api array auto autoincrement beginner binary broken cakephp checkbox class classes cms code cron curl database date destroy display domain dynamic echo email error errorlog file files folder form format forms function functions google href htaccess html if-else image include insert interactive ip java javascript joomla limit link load login mail malfunctioning masterthesis menu mlm multiple mysql nodes oop paypal pdf php popup problem query radio ram random record recursion reference remote return script search server sessions sms source space sql syntax system table tutorial unset update upload url validation validator variable video web websitecontactform youtube





