简体   繁体   中英

Get a parameter value in JavaScript

In Cognos 8.4, I have a prompt, "NAME" , and its parameter p_name.

How do I get that parameter through JavaScript?

<script>
    alert(p_name)
</script>

shows a JavaScript error. Why?

Is my approach correct?

Maybe the reference for the object will be missing, and you have to keep up with the scope of the variables or the parameters. You can use the " Developer Tools " in Internet Explorer 8 by pressing " f12 ". There in the right hand side pan you can choose the tab " console " to find where you went wrong or you can choose the tab " locals " to find whether the parameter has any values in the scope where you are calling it.

I don't know Cognos, but your problem is that you are calling a variable that is local to an object in the global scope. You have to do whatEverTheObjectIsCalled.p_name (probably). An easy way to find out exactly what you are looking for is to fire up the web page in Chrome and console.log(theObject) and browse through the internals of the object until you find the attribute you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM