| | |
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 |
advanced apache api array basics beginner binary broken cakephp check checkbox class cms code codingproblem combobox cookies cron curl database date datepart display dynamic echo email error file files folder form forms function functions google head href htaccess html image include includingmysecondfileinthechain insert ip javascript job joomla js limit link login mail menu mlm mobile multiple mysql nodes oop outofmemmory paging parse password paypal pdf php problem procedure query radio random recursion remote script search server sessions smarty sms source space sql stored syntax system table traffic tutorial unicode up-to-date update upload url validation validator variable video web webapplications youtube





