Log in

View Full Version : button value to hyperlink?, help



camel101
04-24-2007, 03:39 AM
I have a logout button which this code:

<input name=Button type=button class=button tabIndex=5 onClick="location.href='?logout';" value="Logout" on>

I need to change it to an html link without a button image to fit this sequence:

<a href="http://mysite.com/logout" title="Logout">Logout</a>


So basically I need the link to be changed from a button to a hyperlink so I can put it as a header :D

djr33
04-24-2007, 04:41 AM
The location that takes you to is [currentpage.ext]?logout ...just link to that.

camel101
04-25-2007, 01:03 AM
I did try that and it did not work.

To make it more clear, i want to change a submit button to a hyperlink. Is this even possible?

Thanks

djr33
04-25-2007, 01:10 AM
Ah, you could make the link go to the same place but the submit button cannot be accessed by a link... kinda.

There are two workarounds--
1. Style the button to act like a link. Simple enough. Not sure on the CSS, but it's possible.
2. Use javascript--
<a href="javascript:onClick(document.formname.submit());">link</a>
I'm not sure on the specific code... but I think that may work. Basically, you just need to do the javascript function make it submit, rather than going to an actual link. But it will require javascript be enabled.

jscheuer1
04-25-2007, 01:49 AM
The literal translation of this:


<input name=Button type=button class=button tabIndex=5 onClick="location.href='?logout';" value="Logout" on>

to a link would be:


<a href="?logout">Logout</a>

Clicking on a link like that will reload the page and add the query string:

?logout

to the address in the address bar. If the page is a server side page (.asp, .php etc.), and is written to detect that query string and act on it, it will do so. Also, if it has javascript on it to detect that string and act on it, and the user has javascript enabled - it will happen that way too.

However, ?logout isn't your usual type of query string so, there may be problems because of that

camel101
04-25-2007, 02:39 AM
It was a server-side script and possibly the CSS that was messing things around but now I have it all fixed :)

Thanks for the help Mods