cancel
Showing results for 
Search instead for 
Did you mean: 

Change web item attribute value with JavaScript

Former Member
0 Kudos

Hi,

I'm trying to dynamically change a Web item attribute value - to be specific, CAPTION of Role Menu - with JavaScript on page load, but I have a problem. I can't seem to flush the new value without calling SAPBWOpenURL().

I'm hoping to find a way to update the attribute value once the page load is done without refreshing the page using SAPBWOpenURL().

Does anyone know a way to do this?

Thank you in advance,

Hsiao-Chun Wu

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member184494
Active Contributor
0 Kudos

hsiao ,

are you displaying the query through portal ? options to acheive what you want could be .

1. have a prequery page which takes the input of the role and then goes to the query page showing the relevant heading

2. autorefresh of the page

3. use client side eventing to event between two iviews on portal

4. use frames

If the query is large , it is better to go for the first option and the simpler ones of the above are 1 ,2 and 4.

Arun

Former Member
0 Kudos

This might work if you've chosen to display your role menu as an IFRAME

add this code to the <head> of the document

<script>

var newRoleTitle = "New Role Title";//add desired role title here

var roleMenu = "ROLEMENU_1";//stores the name of the rolemenu item

function getRoleTitle(){

var prop = SAPBWGetItemProp( roleMenu );

if (prop != null){

for(i=1;i<prop.length;i++){

if ( prop<i>[0] == "CAPTION" ){

return prop<i>[1];

}//end if

}//end for

return null;

}//end if

}//end function

function updateRoleTitle( ){

var oldRoleTitle = getRoleTitle();

var tds = document.getElementsByTagName("td");

for( var i=0;i<tds.length;i++ ) {

if( tds<i>.innerText == oldRoleTitle ){

tds<i>.innerText = newRoleTitle;

break;

}

}

}//

window.attachEvent("onload",updateRoleTitle);

</script>

Former Member
0 Kudos

Hi David,

Thank you for providing the codes. I tried your it, but no luck. The following call does not seem to work (and in Netscape, it complains window.attachEvent is not a function):

window.attachEvent("onload",updateRoleTitle);

My role menu display the new role title, then stops there, leaving the rest of the role menu blank.

How can I do to make this work?

Thank you in advance!

Hsiao-Chun Wu