cancel
Showing results for 
Search instead for 
Did you mean: 

HTMLB RadioButton

Former Member
0 Kudos

Hi

I am using a HTMLB radioButton in a JSPDynpage.

I have a radiobutton group consisting of 2 radio buttons.

I am unable to get the selected value in Javascript.

I am using the following code

(eval(func("radiobuttonId"))).getChecked();

I get an error

"Undefined is null or not an object"

Can somebody help out please.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Alkesh,

Welcome to SDN. You need to do the following.

1. Make sure you set the following attribute of each radio button.

jsObjectNeeded="TRUE"

2. You need to do the following to get the radio button object. The "radiobutton" refers to id of each radio button and not the group id.

var rb = eval(func(htmlb_radiobuttonmodifier+"radiobutton"));

Former Member
0 Kudos

Hi Prakash

I tried your suggestion but it still doesn't work.

I have pasted my JSP code here so that you can have a look.

Towards the end there is a javascript function openwindow() where I am trying to alert the radio button values.

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

<%@ page import = "com.sapportals.htmlb.enum.EventTrigger" %>

<% String buttonid = "";%>

<jsp:useBean id="ProductInfoBean" scope="application" class="bean.ProductInfoBean" />

<hbj:content id="myContext" >

<hbj:document>

<hbj:documentHead title="test"></hbj:documentHead>

<hbj:documentBody>

<hbj:form id="myFormId" >

<hbj:gridLayout

id="myGridLayout1"

debugMode="False"

width="40%"

cellSpacing="5"

>

<hbj:gridLayoutCell

rowIndex="1"

columnIndex="1"

width="10%"

horizontalAlignment="LEFT"

>

<hbj:textView

text="Title"

id="txtTitle"

tooltip="Title"

encode="false">

</hbj:textView>

</hbj:gridLayoutCell>

<hbj:gridLayoutCell

rowIndex="1"

columnIndex="2"

width="10%"

horizontalAlignment="LEFT"

>

<hbj:inputField

id="ipTitle"

type="String"

invalid="true"

width="100"

value=""

visible="true"

disabled="false"

required="false"

maxlength="30"

size="50"

design="standard"

jsObjectNeeded="true"

>

<%

ipTitle.setClientEvent(EventTrigger.ON_KEYDOWN,"handle_enter()");

ipTitle.setClientEvent(EventTrigger.ON_CHANGE,"handle_titleChange()");

%>

</hbj:inputField>

</hbj:gridLayoutCell>

<hbj:gridLayoutCell

rowIndex="2"

columnIndex="1"

width="10%"

horizontalAlignment="LEFT"

>

<hbj:textView

text="Promotion"

id="txtPromotion"

tooltip="Promotion"

encode="false">

</hbj:textView>

</hbj:gridLayoutCell>

<hbj:gridLayoutCell

rowIndex="2"

columnIndex="2"

width="10%"

horizontalAlignment="LEFT"

>

<hbj:dropdownListBox

id="ddPromotion"

tooltip="Promotion"

disabled="false"

jsObjectNeeded="true"

>

<hbj:listBoxItem

key=""

value="- Select Promotion -"

/>

<%for(int i=0;i<ProductInfoBean.getPromotions().size();i++){%>

<hbj:listBoxItem

key="<%=(String)(ProductInfoBean.getPromotions().elementAt(i))%>"

value="<%=(String)(ProductInfoBean.getPromotions().elementAt(i))%>"

/>

<%}%>

<%

ddPromotion.setClientEvent(EventTrigger.ON_CHANGE,"handle_promotionChange()");

%>

</hbj:dropdownListBox>

</hbj:gridLayoutCell>

<hbj:gridLayoutCell

rowIndex="3"

columnIndex="1"

width="10%"

horizontalAlignment="LEFT"

>

<hbj:textView

text="Selection #"

id="txtSelection"

tooltip="Selection #"

encode="false">

</hbj:textView>

</hbj:gridLayoutCell>

<hbj:gridLayoutCell

rowIndex="3"

columnIndex="2"

width="10%"

horizontalAlignment="LEFT"

>

<hbj:inputField

id="ipSelection"

type="String"

invalid="true"

width="100"

value=""

visible="true"

disabled="false"

required="false"

maxlength="30"

size="50"

design="standard"

jsObjectNeeded="true"

>

<%

ipSelection.setClientEvent(EventTrigger.ON_KEYDOWN,"handle_enter()");

ipSelection.setClientEvent(EventTrigger.ON_CHANGE,"handle_selectionChange()");

%>

</hbj:inputField>

</hbj:gridLayoutCell>

</hbj:gridLayout>

<hbj:radioButtonGroup

id="rbgTypeSelect"

columnCount="2"

selection="rb_artwork"

>

<hbj:radioButton

id="rbArtwork"

text="Artwork"

key="rb_artwork"

tooltip="Extranet"

disabled="false"

jsObjectNeeded="true"

>

</hbj:radioButton>

<hbj:radioButton

id="rbProductDetails"

text="ProductDetails"

key="rb_productDetails"

tooltip="OVLC"

disabled="false"

jsObjectNeeded="true"

/>

</hbj:radioButtonGroup>

<hbj:button

id="searchButton"

text="Search"

tooltip="Please click to search"

disabled="false"

onClientClick = "openWindow()"

jsObjectNeeded="true"

>

</hbj:button>

</hbj:group>

</hbj:form>

</hbj:documentBody>

</hbj:document>

<script language="javascript">

function clearSearchCriteria(){

var funcName = htmlb_formid+"_getHtmlbElementId";

func = window[funcName];

(eval(func("ipTitle"))).setValue("");

(eval(func("ipSelection"))).setValue("");

(eval(func("ddPromotion"))).setValue("");

}

function handle_enter(){

var src= window.event.srcElement;

k = window.event.keyCode;

if (k == 13) {

// enter key pressed

openWindow();

}

}

function handle_titleChange(){

var funcName = htmlb_formid+"_getHtmlbElementId";

func = window[funcName];

var title = (eval(func("ipTitle"))).getValue();

if(title != "")

{

(eval(func("ipSelection"))).setDisabled(true);

(eval(func("ddPromotion"))).setDisabled(true);

}

else

{

(eval(func("ipSelection"))).setDisabled(false);

(eval(func("ddPromotion"))).setEnabled(true);

}

}

function handle_selectionChange(){

var funcName = htmlb_formid+"_getHtmlbElementId";

func = window[funcName];

var selection = (eval(func("ipSelection"))).getValue();

if(selection !="")

{

(eval(func("ipTitle"))).setDisabled(true);

(eval(func("ddPromotion"))).setDisabled(true);

}

else

{

(eval(func("ipTitle"))).setDisabled(false);

(eval(func("ddPromotion"))).setEnabled(true);

}

}

function handle_promotionChange(){

var funcName = htmlb_formid+"_getHtmlbElementId";

func = window[funcName];

var promotion = (eval(func("ddPromotion"))).getValue();

if (promotion!=""){

(eval(func("ipTitle"))).setDisabled(true);

(eval(func("ipSelection"))).setDisabled(true);

}

else

{

(eval(func("ipTitle"))).setDisabled(false);

(eval(func("ipSelection"))).setDisabled(false);

}

}

function openWindow(){

var funcName = htmlb_formid+"_getHtmlbElementId";

func = window[funcName];

var title = (eval(func("ipTitle"))).getValue();

var selection = (eval(func("ipSelection"))).getValue();

var promotion = (eval(func("ddPromotion"))).getValue();

// var selType = (eval(func("rbProductDetails"))).getChecked();

var rb = eval(func(htmlb_radiobuttonmodifier+"rbArtwork")).getChecked();

var rb2 = eval(func(htmlb_radiobuttonmodifier+"rbProductDetails")).getValue();

alert("rb cheked " + rb);

alert("rb2 value " + rb2);

}

</script>

</hbj:content>

Former Member
0 Kudos

Hi Alkesh,

I found a bug with radio control's javascript api. I wrote a weblog which has solution for your problem.