javascript - How do I pull values from a radio button with a label? -
in regards question getting text of radio button instead of values, how pull values radio button label?
i did not post question there, fealt did not go original question.
how value of selected radio? have tried both $("input[type='radio'][id='rblunitofmeasuretype']:checked").val()
, $("input[type='radio'][id='rblunitofmeasuretype']:checked + label").val()
, both return undefined.
i using form, form there tag, rest of html formless form (if makes sense).
function listunitofmeasureset_change() { if (listunitofmeasureset.value.tostring().tolowercase() === "new") { $("#divnewtypeunitcontentholder").html(""); callservice("get", g_webserviceunitsofmeasuretypeunitsurl, null, function(jsonresult) { if (jsonresult.success) { (i = 0; < jsonresult.unitofmeasuretypelist.length; i++) { $("#divnewtypeunitcontentholder").html($("#divnewtypeunitcontentholder").html() + '<input type="radio" id="rblunitofmeasuretype' + + '" name="rblunitofmeasuretype" value="' + jsonresult.unitofmeasuretypelist[i].id + '" /><label for="rblunitofmeasuretype' + + '">' + jsonresult.unitofmeasuretypelist[i].name + '</label> ' + jsonresult.unitofmeasuretypelist[i].description + '<br />'); } } }); $("#divnewunitofmeasure").dialog("open"); } }
the first 1 should work, option use .attr('value')
$('input').click(function(){ console.log($("input[type='radio'][id*='rblunitofmeasuretype']:checked").val()); console.log($("input[type='radio'][id*='rblunitofmeasuretype']:checked").attr('value')); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <input type='radio' id='rblunitofmeasuretype' value='15'> <input type='radio' id='rblunitofmeasuretype4' value='17'>
Comments
Post a Comment