•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 361,946 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,659 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 452 | Replies: 3
![]() |
•
•
Join Date: Mar 2008
Posts: 64
Reputation:
Rep Power: 0
Solved Threads: 1
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
<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:
Rep Power: 1
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?
<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
<a href="http://www.webs.com/hi.html"><img src="button.gif" /></a>
Sage
•
•
Join Date: Nov 2007
Posts: 86
Reputation:
Rep Power: 1
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
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>![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
Similar Threads
- PHP 2 MsSQL (PHP)
- how can i make php alert pop ups just like in javascript. (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?


Linear Mode