Skip to Content
author's profile photo Former Member
Former Member

Getting value from HTMLB radiobutton error...

Hi, I am getting an Javascript error saying <b>"selectedRadioValue has no properties"</b> with the following code. When the user clicks the a radio button, there is an alert displaying the selected radio button text. I was wondering if anyone can see what is wrong in my short code below?

Thanks so much, Baggett

<b><%@ taglib uri="tagLib" prefix="hbj" %>

<SCRIPT LANGUAGE="JavaScript" TYPE="text/JavaScript">

function alertSelectedRadio(){

var funcName = htmlb_formid+"_getHtmlbElementId";

func = window[funcName];

var selectedRadioValue = eval(func(htmlb_radiobuttonmodifier+"TestRadioButton"));

var radiotext = selectedRadioValue.getText();

alert("*** The radio button you selected is = " + radiotext);

} </SCRIPT>

<hbj:content id="myContext" >

<hbj:page title="Initial Page">

<hbj:form id="myFormId">

<hbj:gridLayout width="50%" >

<hbj:gridLayoutCell rowIndex="1" columnIndex="1" style="">

<hbj:radioButtonGroup id="TestRadioGroup" columnCount="2" selection="rb_fem">

<hbj:radioButton id="TestRadioButton" text="female" key="rb_fem" tooltip="I am female" jsObjectNeeded="TRUE" disabled="false" />

<hbj:radioButton id="TestRadioButton" text="male" key="rb_male" tooltip="I am male" jsObjectNeeded="TRUE" disabled="false" />

</hbj:radioButtonGroup>

</hbj:gridLayoutCell>

<hbj:gridLayoutCell rowIndex="1" columnIndex="2" style="">

<hbj:button id="button1" text="Get Radio Button Pressed" jsObjectNeeded="TRUE" onClientClick="alertSelectedRadio()" />

</hbj:gridLayoutCell>

</hbj:gridLayout>

</hbj:form>

</hbj:page>

</hbj:content></b>

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jun 16, 2005 at 03:15 PM

    Hi Baggett,

    I found out there is a bug with SAP's code. The only way to get hold of radio button is by using the following code.

    function alertSelectedRadio(){
    var funcName = htmlb_formid+"_getHtmlbElementId";
    func = window[funcName];
    //you have to specify the group name
    var selectedRadioValue1 = eval(func("TestRadioGroup" + htmlb_radiobuttonmodifier.substring(3,7)+ "1"));
    var selectedRadioValue2 = eval(func("TestRadioGroup" + htmlb_radiobuttonmodifier.substring(3,7)+ "2"));
    alert(selectedRadioValue1.getValue());
    alert(selectedRadioValue1.getChecked());
    alert(selectedRadioValue2.getValue());
    alert(selectedRadioValue2.getChecked());
    
    }

    Message was edited by: Prakash Singh

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 14, 2005 at 08:41 PM

    to check which radio is checked you use the following property.

    selectedRadioValue.isChecked() 

    <b>Note: Your code has same id for both the radio buttons. They should have different id.</b>

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Prakash, thank you for your response. The error is happening inside the conditional "if" statement, where I try to access the selectRadioValue1 object:

      <b>if ( selectedRadioValue1.isChecked()){

      var radiotext1 = selectedRadioValue1.getText();</b>

      I then get the <b>"selectedRadioValue1 has no properties"</b> error message. Somehow maybe I am not creating my radio group right?

      Prakash, would you like me to paste my entire code? It is pretty short.

      Thanks so much,

      Baggett.

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.