I'm not sure what you mean by "init" functions, but here are a few JS tips:
1. JS is entirely case-sensitive with respect to vars *and* function names.
2. JS statements in most cases must terminate with semi-colons.
3. Whatever you have posted below is incomplete and/or makes no sense (transition from 2nd to 3rd line).
4. Variables declared in a function are local to that function. Outside your function theUrl, for example, does not exist.
5. Where do you see "THEURL not found"? In VFP? In your browser?
6. An Alert() call does not need the quote marks.
7. Assuming you're using VFP 8/9, you can avoid "delimiter hel1" by wrapping JS in TEXT TO/ENDTEXT, rather than concatenating strings in code. Ex:
LOCAL lcJS
TEXT TO lcJS NOSHOW PRETEXT 3
function Radio_Click(theCourseId){
var theUrl = "..." ;
alert(theUrl) ;
return theUrl; // presumably
}
ENDTEXT
lcJS = TEXTMERGE(m.lcJS)
>I am working throug a VFP ISAPI COM that responds to the browser with javascript.
>
>I hacked around an issue today useing the js "var" to assign varibles (in js) when the browser received the page.
>
>I [think] I made a correlation. the "var" pre-cast seems only to be effective in functions other than "init" functions designated by an "onload".
>
>Color me java green. Here is a snip (forgive the delimeters code is from VFP COM(:
>[function Radio_Click(theCourseId){]+CR+;
>[var theUrl="HTTP://Somehost/scripts/foxISAPI.dll/MyCOM.myClass.myMethod?pwd="thePwd]+CR+;
>[alert("]+theUrl+[")]
>THe above returns the url. But, when I do it inside an init called by a js "onload", I get a "THEURL" (note all upper case) Not found. In fact, the var assigment in an onload will not recognize any var (or so it seems) assignmens. I have not tried with "new string" casts.
>
>I solved it by assembling the "var" in VFP above before the script response. Is "var" restricted in a js onload call?
>
>I must confess that I also spent several hours chasing down one problem when all I needed to do was assure I had the case of the variable names agree.