Trying to change out a radio button with a small image for selection of products
I am trying to write some java开发者_运维问答script that will pull information out of a page when it loads and replace the radio buttons with a small image instead of the button. Also when the button is clicked on I need it to replace the large image on the screen. Is this something that can be done with Javascript alone or do I need PHP? I understand PHP but with the site I cant use it. I am stuck. I am happy to answer all questions about this. I am kind of stuck. Please help
Here's a script I found to replace the radio buttons (and checkboxes and select dropdowns) with styling of your choice.
I recommend you read the short article before you jump into using it.
ryanfait.com
Also, the script for changing a larger image would be something like:
$('.radio').change(function(){
$('#lgImg').src(newUrl);
});
Where newUrl
would be based on some value of the radio button that was changed like: $(this).attr('data-img-url')
Finally, just as a side note, you wouldn't be able to do anything like this (client-side) in PHP unless you submitted the radio button on change (again, with Javascript) and reloaded the page with the correct larger image. But that would be very dirty and fairly unnecessary.
精彩评论