views:

51

answers:

5

I have buttons on a page that look like:

<p>
    <a href="view.php">
      <input type="button" name="view" value="View Database" />
    </a>
</p>

IE does not support these buttons or multiple buttons I am not sure which one. Does anyone know how to fix this to work with IE?

+3  A: 

Embedding a button within an <a> tag is not normally done, and really doesn't make any sense. If you want your link to look like a button, then just use the <input> tag with some script on the onclick event, or use css to make your link look button-ish (start by using display:block or display:inline-block);

Ray
+1  A: 

What exactly are you trying to achieve? If you want a custom button to redirect to view.php, you can use onclick:

<input type="button" name="view" value="View Database" onclick="window.location.href='view.php';" />

or something similar.

Andy Shellam
Thanks. This is helpful
shinjuo
+1  A: 
<input type="button" 
onclick="javascript:document.location='view.php';" 
value="View Database"/>
egrunin
+3  A: 

You can't put an input into the tag, instead, you can create a form, and change your button to a submit one. Then you can choose the target url in the form, like this:

<form action="view.php">

    <input type="submit" name="view" value="View Database" />

</form>

I would recommend this over using javascript, because buttons are not designed for navigating a site. If you want to submit information, which is what they are used for, you won't be able to do it so cleanly using javascript.

SLC
+1 good solution, I never thought of using a small form for this. I would however add `method="GET"` to the `<form>` tag - the target page may behave strangely with a POST when theoretically it's only viewing it to begin with.
Andy Shellam
@Andy, `GET` is the default method for a form.
mercator
@mercator - oh right cool, I thought it was POST.
Andy Shellam
+1  A: 

Try with this ugly monster:

<input  type="button" name="view" value="View Database" onclick="javascript:window.location='view.php'"/> 
systempuntoout
Thanks this works
shinjuo
you are welcome :)
systempuntoout
Why do you have a label called 'javascript' in there? https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Statements/label
David Dorward
Uhm, what does your link mean?Javascript is not mandatory, you are right.
systempuntoout