Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

input type=image 2

Status
Not open for further replies.

sfenx

Programmer
Feb 23, 2001
81
BE
I have written some simple code in ASP (see below) with 2 submit buttons. Is there a way to replace the submit buttons by an image? I already used type="image", but I read that the value option of this type doens't work. I know there must be a 'onclick='-command to define the 'lang'-variable. Or are there other ways to do it? Who can help me on this?

Code:
<BODY>
	<% lang = request.form(&quot;language&quot;) %>
	<% if lang = &quot;2&quot; then %>
		ENGLISH
	<% else %>
		DUTCH
	<% end if %>

	<FORM action=&quot;[URL unfurl="true"]http://mysite.asp&quot;[/URL] method=&quot;post&quot;>
	<INPUT name=&quot;language&quot; type=&quot;submit&quot; src=&quot;/jpg/NLbutton.jpg&quot; value=&quot;1&quot;>
	<INPUT name=&quot;language&quot; type=&quot;submit&quot; src=&quot;/jpg/ENbutton.jpg&quot; value=&quot;2&quot;>
	</form>
</body>[\code]
 
try:

<input type=&quot;submit&quot; style=&quot;background-Image:url(/jpg/ENbutton.jpg)&quot; value=&quot;1&quot;>
 
Thnx for reacting so soon guys.
Sjravee: your option works fine, but the disadvantage is that I can't hide the value on the button.
Tony: I agree on giving different names to the buttons, but then I have to write a whole lot more code i.e. if I have 5 languages to chose from
Erik: thnx for the links. There are some pretty good scripts there.
Still it surprises me that one can't give a specific value to an <input type=image>. Anybody knows the reason for this? When (and how) do you use the x and y value coördinates anyway?
 
the reason you cant assign it a value is because its not meant to be a value container, its job is to submit a form. Why not use a hidden field to assign the value to so when a user presses the submit button
<FORM name=&quot;Form1&quot; action=&quot; method=&quot;post&quot;>
....
<input type=hidden name=&quot;Lang&quot;>
<input type=image src=&quot;/jpg/NLButton.jpg&quot; onclick=&quot;document.Form1.Lang.value='1'&quot;>
<input type=image src=&quot;/jpg/ENButton2.jpg&quot; onclick=&quot;document.Form1.Lang.value='2'&quot;>


then in your asp read the value of Lang,

lang = request.form(&quot;Lang&quot;)
 
Sjravee, thanks a lot. You realy helped me out here! This is just what I was looking for! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top