0

See my demo page for where I have it working on an img src but not an input which is what I really want.

Here's the link to my testing / demo page: http://www.myu2sig.com/stellardonations/buttontype.php

As for what I want to do, how can I apply the function to the input so it's image changes on the value of the select like the regular image does which uses HTML's img src.

As for all of the code that produces what you see on said page:

<script type="text/javascript">
	function showimage(t){
		if (!document.images)
		return;
		document.images[t.getAttribute("name").replace("select","pics")].src=t.options[t.selectedIndex].value
	}
</script>

Regular Image using: < img name="firstpics" src="/stellardonations/paypaldonate.gif" ><br />
<img name="firstpics" src="/stellardonations/paypaldonate.gif">

<br /><br />

Input Image using: < input name="firstpics" type="image" src="/stellardonations/paypaldonate.gif" border="0" name="submit" ><br />
<input name="firstpics" type="image" src="/stellardonations/paypaldonate.gif" border="0" name="submit">

		<br /><br />
		
		<select name="firstselect" onChange="showimage(this)">
		<option value="/stellardonations/paypalsubscribe.gif">Yes</option>
		<option selected="selected" value="/stellardonations/paypaldonate.gif">No</option>
		</select>
		
		<br /><br />
		
		No = Donate<br />
		Yes = Subscribe
2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by MoreBloodWine
0

Ps; I know I have name="" twice on the input, that was a typo but the fact remains I would like to apply the image change to the inputs source based on the selected value of the drop box.

0

Do you mean you want to cooperate 'input' tag with a function call? You can use onclick() event.

//i.e. in javascript
<script type="text/javascript">
function clickItAlready(arg1Str, arg2Num) {
  alert(arg1Str+":"+arg2Num)
}
</script>

// in HTML
<input type="image" src="/stellardonations/paypaldonate.gif" border="0" name="submit" onclick="clickItAlready('my string argument', 777)">
0

What I want to is is have the inputs image change based on the selection of the select box. So if Yes is chosen the inputs image changes o a subscribe button and if No is ticked the input remains a donate button.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.