Jump to content


Photo

How to make a submit button a link


  • Please log in to reply
3 replies to this topic

#1 OriginalSunny

OriginalSunny
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts

Posted 27 March 2006 - 08:44 PM

Hi,
instead of having the standard link (blue text underlined) i want to make a link to another page using a submit button. The code i have used for the button is below.

echo "<tr>
<td colspan='2'> <input type='submit'
value='Return to orders menu'></td>\n";


As you can see this will not actually do anything except display the button. The question is how do i make this into a link? (I have used this code on my .php page and am not reading anything in from a .ini page and hopefully wont have to unless i need to).
Thanks.

#2 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 27 March 2006 - 10:06 PM

You have to put it inside a form and set the 'action' attribute of the form to the url you want. BUT WHY????

all that hassel just for a link and you aren't even sending any data! I'd just use an image for the link if you don't want the 'plain' text or better still use css well and create a funky link! Latter is much better for accessibility!
follow me on twitter @PHPsycho

#3 azuka

azuka
  • Members
  • PipPipPip
  • Advanced Member
  • 55 posts
  • LocationNigeria

Posted 28 March 2006 - 12:07 AM

You can simply say
<button onclick="self.location.href='your url'" type="button">Button Text</button> but what happens when there's no javascript?

Given enough eyeballs all bugs are shallow. My Website

#4 txmedic03

txmedic03
  • Members
  • PipPipPip
  • Advanced Member
  • 313 posts
  • LocationCall, TX, USA

Posted 28 March 2006 - 03:56 AM

I would suggest using images for the simple fact that some people turn javascript off in their browser and using a form for each link in your site just leads to lots of superfluous code. Then of course the obvious question is, do you have any idea of the capability of CSS in this matter? You do know that the text does not have to be underlined or blue, right? You can even make the background behind it change colors.

SEMPER FIDELIS!

I can't stop you from doing something silly, but at least I can help you do it right.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users