Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
passing value to formApi function
cliffhanger
Hi,
I am executing a server call from my FormApi code, which does some background work, and then makes a call back to the FormApi to set a variable.
The back-end perl code works okay as I know from the LOG that file is creating, but for some reason it doesn't seem to get to the javascript code.
this is how it looks:
print <<EOF;
<html>
<script language="JavaScript">
function setValue()
{
alert("HELP HELP HELP!");
self.close();
if($value>=0)
{
parent.getScriptFrame.setValue(true);
}
else
parent.getScriptFrame.setValue(false);
}
</script>
<body onLoad="setValue()">
</body>
</html>
EOF
It doesn't even give me the alert! For my callServer() I am passing"true" for isGet.
Could somebody please help?
Thanks
-cliffhanger
Find more posts tagged with
Comments
Dwayne
You've got a syntax error in your JS:
<html>
--
Current project: TS 5.5.2/6.1 W2K
cliffhanger
Hi Dwayne,
I fixed those syntax errors and took out that self.close() line, yet no progress
Thanks
-cliffhanger
brandon1
getScriptFrame is a function it needs to be this getScriptFrame()
print <<EOF;
<html>
<script language="JavaScript">
function setValue()
{
alert("HELP HELP HELP!");
self.close();
if($value>=0)
{
parent.getScriptFrame
()
.setValue(true);
}
else
parent.getScriptFrame
()
.setValue(false);
}
</script>
<body onLoad="setValue()">
</body>
</html>
EOF
Current Project: Content Services implementation
cliffhanger
Hi Brandon,
Silly mistakes that people make!! Thanks!
But I wish could tell that was the error! I have javascript debugging turned on, so it should've given me a error if it ever got there!! Unfortunately it seems like it's completely ignoring the HTML block of code.
How can I make sure that it executes that block?
Thanks a lot
-cliffhanger
brandon1
When you say:
I have javascript debugging turned on
If you are running ie do you have
Display a notification about about every script error
checked in Internet Options -- Advanced Tab checked?
Current Project: Content Services implementation
brandon1
Also FireFox
http://www.getfirefox.com
has a nice javascript debugging console that might be helpful as well.
Current Project: Content Services implementation
cliffhanger
Hello Brandon,
"Display a notification about about every script error" is also checked at IE options. As I mentioned earlier, I would be happier rather it it threw me some error! It seems to be completely ignoring that block of code
any thought?
-cliffhanger
brandon1
If you have Microsoft Script debugger you can attach to the process and it *might* show you the error. Microsoft Script Debugger is usually included with Microsoft Office and could be located here
[Your Program files Path]\Microsoft Office\Office[version]\MSE7.EXE
Current Project: Content Services implementation
cliffhanger
Hi,
I got this problem fixed. I appreciate everyone's help, thank you.
I was tracing the order in which the line of codes are executed, and I am left with a shocking surprise!
From the server call I am making, my understanding is that the setValue() in my FormAPI code should get called(from the CGI's Javascript code) before callServer() returns. In reality I don't see that happening. Is this because of asynchronous nature of callServer()?? What happens in my case is, the callServer() returns before the CGI Javascript sets the value in the FormAPI. My guess is that the easiest way to handle this would be keeping a busy loop after the callServer() before trying to access value that would set by callServer(). Does anyone else have a better idea?
Thanks,
Cliffhanger
Dwayne
You are correct that callServer will return before the CGI has finished execution. This is documented behavior.
As far as waiting is concerned: do you really need to? All you're doing is setting a value of one of the fields. Is it important that your DCR form "go to sleep" while the CGI is running?
If it really is important (it's part of an onSave event or something) then you'll probably have to use a setTimeout routine to poll for when the value has been updated. Don't just loop - you'll chew up all of the CPU resources allocated to the browser, and the JS you generate in your CGI won't ever get a chance to execute.
--
Current project: TS 5.5.2/6.1 W2K
cliffhanger
hi Dwayne,
Yes it is part of an onSave event. Thanks for the suggestions, I guess I could use a setTimeout routine to poll for updated value
-cliffhanger
brandon1
Or just have the callServer javascript call the "next" function indicating completion.
Current Project: Content Services implementation
cliffhanger
Hi Brandon,
the problem is there's no "next" function, this callServer is part of an onSave event.
-cliffhanger
cliffhanger
Hi Dwayne,
the asynchronous nature of both setTimeOut and callServer is haunting me....is there any other better way to go to sleep? I agree with you that a busy loop will take up all of the CPU resources allocated to the browser, so that's not a "real" solution either
thanks
-cliffhanger
Dwayne
Unfortunately, JS doesn't have a "sleep" function.
Since this is part of an
onSave
event, why not use Brandon's suggestion. There's no reason why you can't
create
a "next" function. Have your
onSave
handler invoke the
callServer
, and then return
false
, causing the save to stop. You can then have the "next" function that your CGI calls invoke the
save()
method to actually save the DCR.
--
Current project: TS 5.5.2/6.1 W2K
cliffhanger
Thanks Dwayne, now Brandon's suggestion is clearer to me
-cliffhanger