on 04-05-2006 8:59 AM
Hello @ all,
I want to use a value of a Javascript array in a HTML like
<script>
var array=new Array();
<b>array[0]</b>=Value1;
array[1]=Value2;
</script>
<a class=SAPBEXBtnStd href="<SAP_BW_URL cmd='LDOC'TEMPLATE_ID='TEST'+<b>array[0]</b>>">to TEST</a>
How can I do this?
I would suggest an alternative solution. I notice you are using Web Commands. Instead of using the Web Commands in tags (<SAP_BW_URL cmd='LDOC' TEMPLATE_ID='TEST'>), I would suggest you write the javascript yourself.
Example:
<script>
var myArray = new Array();
myArray[0] = "hello";
myArray[1] = "world";
myHTMLpath = SAP_BW_URL_Get() + "&CMD=LDOC" + "TEMPLATE_ID=" + myarray[0] + myArray[1];
//output the link to the screen
document.write('<a class=SAPBEXBtnStd href=' + myHTMLpath + '>Click Here to Test</a>');
</script>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mehmet,
as far as I understand your problem, you're mixing up server side und client side dynamics and scripting.
First of all the statement
href="<SAP_BW_URL cmd='LDOC'TEMPLATE_ID='TEST'+array[0]>"
is parsed and replaced on the server and generates some html-code-fragement like this
href="http://server/bw-url/ldoc-cmd?template_id='TEST+array[0]'
At this moment the array is part of a string and not a javascript-variable. No way to get this into the correct form.
The only way imho to avoid this problem is:
1. Let the server store the url to your bw-server in a javascript-var
var serverLink=SAP_BW_URL cmd='LDOC'TEMPLATE_ID='TEST'>
-> problem is: the template 'Test' musn't exist!?!
2. Append the array value to the generated url on click:
<script>....
function navi(pos) {
document.location.href = serverLink+array[pos];
}
</script>
<a href="javascript:navi(0)">to Test</a>
Something like this could work..
Hope that helps, Thomas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you can't pass variable directly (except document.write)
I think the best way to solve problem is making javascript function
eq.
<script>
var array=new Array();
array[0]="Value1";
array[1]="Value2";
function openWin(a)
{
window.open("<SAP_BW_URL cmd='LDOC'TEMPLATE_ID='TEST'"+array[a], "_self")
}
</script>
<a href="javascript:openWin(0)">to TEST</a>
in openWin(), in a href, put variable you want
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.