| | |
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 |
apache api array beginner binary broken cache cakephp checkbox class cms code confirm cron curl customizableitems database date display dynamic echo email error external fcc file files folder form forms forum freelancing function functions google header headmethod howtowriteathesis href htaccess html iframe image include insert ip javascript joomla limit link login mail malfunction menu method mlm mod_rewrite multiple mysql neutrality oop pageing pagerank paypal pdf php phpmysql play problem query question radio random recursion remote root script search select server sessions sms soap source space sql support! syntax system table template tutorial update upload url validator variable video web youtube





