Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.
Javascript image replacement
i first want to ask, how php processing a script? as i written in the topic, i need a javascript, but i want it in a php file. so i need :
,...
?>
javascript.... //javascript
<?php //second php
....
?>```
so can it be done in this way?
also to the main problem, how can i do, i know, i think it can be only done in javascript, an image replacement? there are three radio buttons, and depends on selection, the proper image will be shown.
so how can i do this? thanks.
dancuc wrote: anyway, can you recommend any good article to that js and radio button? i google for this but i dont get that what i need. there was only some equivalent for str_replace() in php, but not for image replace.
Think about how an image actually works. You use the IMG tag and specify the image source with the SRC attribute. So, using Javascript and the DOM, just change the SRC attribute to whatever you want for each radio button; use the onclick() event.
ok, i'm posting:
<img id="image1" src="img1.jpg" />
<img id="image2" src="img2.jpg" style="display:none" />
<br />
<input type="radio" name="radiobutton" onclick="this.checked ? Change('image1') : Change('image2')" checked="true" />
<input type="radio" name="radiobutton" onclick="this.checked ? Change('image2') : Change('image1')" />
</form>
<script language="JavaScript">
/*<![CDATA[*/
function Change(img)
{
var image1 = document.getElementById("image1");
var image2 = document.getElementById("image2");
if(image1 != null && image2 != null)
{
switch(img)
{
case "image1":
image1.style.display = "";
image2.style.display = "none";
break;
case "image2":
image1.style.display = "none";
image2.style.display = "";
break;
}
}
}
/*]]>*/
</script>```