Jared Quinn

IT Consulting :: Design :: Events Management

Ask JaredQuinn
Image Submit and New Windows

“I’m wondering if you could help me. I have an image and i need to give it this as it’s link <input type=submit value=Login>, how can i do it, any ideas? Is there any chance i can get it so it opens in a new window?”

Firstly, without me ranting, I really do not like anything that opens in a new window, unless it is part of an web based application, has a good reason to do so and the action is not unexpected for the user. Apart from that on with answering your question.

The first part is easy, standard HTML, something like the below code snippet should do exactly what you want.

<input type=“image” name=“submit” value=“login” src=“/image.jpg” />

Now to open your form in a new window. I personally think using JavaScript is the best way to do this.

Let’s define a function to do it. This can be inserted anywhere in your HTML.

<script language=“JavaScript”>
<!–
function openWin() {
  var p = window.open(‘’,‘popUp’,’scrollbars=no,resizable=no,h=100,w=200′);
  document.MyForm.target = ‘p’;
}
//–>
</script>

Now we put our form together, noting that the form’s name is the same as the one used in our function.

<form method=“post” name=“MyForm” action=“dest.php” onSubmit=“openWin();”>
<input type=“image” name=“submit” value=“login” src=“/image.jpg” />
</form>

I hope this answers your question sufficiently.





Leave a Reply