This is the dynamic radio button:
echo "<input type='radio' name='q_id' value='.$ans[$i].' id='.$i.'>$ans[$i].";
and here is the submit button:
<input type="submit" name="submit" id="submit" value="Submit" style="border: 0; background: transparent"><img src="images/skip.png" alt="submit_x" width="223" hspace="40" height="49"/>
I want to change the image source in the button the very moment when radio button is clicked. New image source will be "images/next.png"
This change in image has to be done before submitting the form.
Add a class to the radio button to be able to target it via client side code:
$('.myclass').on('change' , function(){
if ($(this).is(':checked'))
{
$('#submit').css("background-image", "url(images/next.png)");
}
});
If you cannot add a class you ll have to echo out the script tag after your initial button echo and echo the id into the selector.