Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WebFocus variable in JavaScript 1

Status
Not open for further replies.

kaeserea

Programmer
Feb 26, 2003
164
0
0
DE
Hello!

When I use JavaScript with HTML and WebFocus (with -HTMLFORM BEGIN and -HTMLFORM END) how can I use WebFocus variables in that JavaScript?

(I defines the varaibles with -SET &NAME = 'xxx';)

Thanx
Eva
 

Hello Eva,

WebFOCUS amper variables are resolved to their text representation before the -HTMLFORM is generated on the web server, so within JavaScript these variables will be simply "the text". Below is a very simple example:

-SET &VARMSG='alert("The message !");';
-HTMLFORM BEGIN
<html>
<head>
<script language=&quot;javascript&quot;>
<!--
function msgAlert() {
&VARMSG
}
// -->
</script>
</head>
<body onLoad=&quot;msgAlert()&quot;>
</body>
</html>
-HTMLFORM END

Hope this helps
Grzegorz
 
Hi Grzegorz!

Thanx a lot, works excellent. For all those who'd like to have an example for an external JavaScript, here it is:
[tt]
-SET &MES = 'Mein Test';

-HTMLFORM BEGIN
<html>
<head>
<script language=&quot;javascript&quot;>
<!--
var message = '&MES';
// -->
</script>
<script language=&quot;javascript&quot; src=&quot;</script>
</head>
<body onLoad=&quot;msgAlert()&quot;>
</body>
</html>

-HTMLFORM END
[/tt]

Where the external JavaScript is the following:
[tt]
function msgAlert()
{
alert(message);
}
[/tt]

Regards,
Eva
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top