Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Returning Radio Button Value

Status
Not open for further replies.

ShaneBrennan

Programmer
May 19, 1999
198
GB
Hi Everyone.. I think I've got brain freeze.

I'm using bootstrap version 3 and I have 2 radio button on a modal with the id "closeProjectDetails".

The code for the radio buttons is:

<div class="control-group btn-group row">
<label class="btn btn-default">
<input type="radio" name="closeOrCancel" value="close" />
<span>Closing</span>
</label>
<label class="btn btn-default">
<input type="radio" name="closeOrCancel" value="cancel /">
<span>Cancelling</span>
</label>
</div>


All I'm trying to do is retrieve the selected value "close" or "cancel"

I found this function on this forum:

function getRadioValue(grp) {
var radioIndex = getSelectedRadio(grp);
if (radioIndex != -1) {
return grp[radioIndex].value ;
}
else {
return -1;
}
}

and tried to use the following to retrieve the value neither of which worked:

theData.closeOrCancel = getRadioValue(closeProjectDetails.closeOrCancel) ;
theData.closeOrCancel = getRadioValue(closeOrCancel) ;

I know it's probably something simple.... but brain hurts and can't work the thing out.

Thank you in advance for any assistance you can give.

Shane Brennan


 
Found the solution to the problem... forget about the function:

theData.closeOrCancel = $('input:radio[name=closeOrCancel]:checked').val();

Works a treat

Shane Brennan


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top