cancel
Showing results for 
Search instead for 
Did you mean: 

Can I change dynamically a dropdownbox's selectedIndex in a BexWebtemplate?

Former Member
0 Kudos

I'm coding directly <SELECT>tags in the HTML source for choosing a filter value by using JavaScript.

But there is a problem regarding the displaying of <SELECT>tag.

We want to see the dropdownlist with the correct selectedIndex value which we have selected.

So I've coded as the following.

When I call this report,the SetSelectedIdx() function doesn't work well.

It always sets '0' to the selectedIndex' value.

Is it possible to set the selectedIndex's value according to the innerHTML?

Would you give me any advice about this?

Best Regards,

Yosuke

<<<<The begin of the Code Sample>>>>

**********Our JavaScript**********

//Function:Set Filter value//

function Set_filter(){

fil_var=document.myForm.mySelect.options[document.myForm.mySelect.selectedIndex].value;

url=SAP_BW_URL_Get() + fil_var;

if (fil_var != "" )

SAPBWOpenURL(url);

}

//Function:Set selectedIndex's value to <SELECT>tag//

function SetSelectedIdx(){

fil_num=document.getElementById("mySelectedVar").innerHTML;

if(fil_num=="11111111"){

document.forms["myForm"].elements["mySelect"].options[1].selected = true;

}else

if(fil_num=="11111112"){

document.forms["myForm"].elements["mySelect"].options[2].selected = true;

}else{

document.forms["myForm"].elements["mySelect"].options[0].selected = true;

}

}

**********HTML Source**********

<BODY topmargin="0" bottommargin="10" onLoad="SetSelectedIdx()">

|

OMISSION

|

<FORM name="myForm">

<TD>

<SELECT name="mySelect" onChange="Set_filter()">

<OPTION value="<SAP_BW_URL DATA_PROVIDER='*' MULTI='X' FILTER_IOBJNM='0GL_ACCOUNT' FILTER_VALUE='!ALL'>">(all)

<OPTION value="<SAP_BW_URL DATA_PROVIDER='*' MULTI='X' FILTER_IOBJNM='0GL_ACCOUNT' FILTER_VALUE='11111111'>

">value1

<OPTION value="<SAP_BW_URL DATA_PROVIDER='*' MULTI='X' FILTER_IOBJNM='0GL_ACCOUNT' FILTER_VALUE='11111112'>">Value2

</SELECT>

</TD>

</FORM>

|

OMISSION

|

<P id='mySelectedVar'>

<object>

<param name="OWNER" value="SAP_BW"/>

<param name="CMD" value="GET_ITEM"/>

<param name="NAME" value="FILTER_2"/>

<param name="ITEM_CLASS" value="CL_RSR_WWW_ITEM_FILTER"/>

<param name="DATA_PROVIDER" value="DATAPROVIDER_1"/>

<param name="GENERATE_CAPTION" value=""/>

<param name="PRESENTATION" value="KEY"/>

<param name="ITEM_FILTER_IOBJNM_1" value="0GL_ACCOUNT"/>

<param name="PRESENTATION_1" value="KEY"/>

<param name="ONLY_VALUES" value="X"/>

ITEM: FILTER_2

</object>

</P>

|

<<<<The End of the Code Sample>>>>

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Yokuke,

you have put the SetSelectedIdx() function in the onload-part of the body tag. This cannot work, because when the page is loaded the filter web item isn't on the page. You have to make new script-tag at the end of your document just before the closing </body>-tag:

<script language="JavaScript">

<!--

SetSelectedIdx();

//-->

</script>

This should work I think.

Greetings,

Daniel

Former Member
0 Kudos

Helloe Daniel,

Thank you for reply.

I've inserted new script tag before the </body>tag, but it doesn't work well.

It seems that this problem is caused by getting value via innerHTML method in the SetSelectedIdx() function.

Because when I set the fixed value(e.g.11111111) to 'fil_num', the SetSelectedIdx() worked correctly.

If you will give me further information about this,

it would be highly appreciated.

Regards,

Yosuke