There is this code that apears several times in my page:
<div>
<input type="hidden" name="product" id="productF3" value="7">
<div>
<input type="radio" name="size" id="size_s" value="3"> small size
</div>
<div>
<input type="radio" name="size" id="size_n" value="4"> regular size
</div>
</div>
I have a problem getting the selected value, starting from the productF3 element.
Right now I’m using this code to solve my problem:
if($("#productF3").next().children("input[@name=size]:checked").val() != undefined) do something
else if($("#productF3").next().next().children("input[@name=size]:checked").val() != undefined) do something
else alert("Select a size");
But I want a more robust solution, any suggestions?
Thanks!
Firstly change
$("productF3")to$("#productF3"). Secondly why don’t you useto get selected radio value?