Thursday, April 5, 2012

HTML, create a button to redirect a link



You may need to create   a button redirect to another page.
Method 1: (When you click search button, redirect to Google website)
 <input type="button"  VALUE="Search" onclick="window.location = 'http://www.google.com';"> 
Result:

Method 2, using form
 <FORM METHOD="LINK" ACTION="http://www.google.com">
<INPUT TYPE="submit" VALUE="Search">
</FORM>


More application:
You can add a edit button  in each of your webpage, for administrator, edit button will showup.
When the edit button is clicked, the page will be redirected to a editable page.
Using PHP
     <?php $redirect_url=$_SERVER['PHP_SELF'].'?edit=1'; ?>
<input type="button"  VALUE="Edit1" onclick="window.location ='<?php  echo $redirect_url;?>';">


No comments:

Post a Comment