Boolean Function Parameter

M

Matt

I have a simple JS function that I want to return a true or false value
based on the parameter passed in. At this point of time I receive the
error "'True' is undefined". Here is my code below.

JS Function -

function ShowSpecifiedPeriod(pShowPeriod){
document.mfperformance.ShowPeriod.value = pShowPeriod
document.mfperformance.method = 'get';
document.mfperformance.action = 'composite_requestdata.asp';
document.mfperformance.submit();
}

ASP Event Handler -

onclick="ShowSpecifiedPeriod(<%If bShowPeriod = false then
Response.Write true else Response.Write false%>)"

The ASP variable bShowPeriod is set based on the hidden form field
"ShowPeriod" and the initial value is set to false.

More than likely this has to do with the boolean Parameter but I am not
sure how to handle this in JS. I have tried the following but receive
the same results.

function ShowSpecifiedPeriod(boolean pShowPeriod) - Same Error
function ShowSpecifiedPeriod(pShowPeriod boolean) - Same Error

Please let me know what I am doing wrong here. Thanks.
 
M

Matt

Figured it out.... I needed to pass the boolena value as a literal
string so I placed double quotes around the boolean value and single
quotes around the parameter.

onclick="ShowSpecifiedPeriod('<%If bShowPeriod = false then
Response.Write "true" else Response.Write "false"%>')"
 
G

Grant Wagner

Matt said:
Figured it out.... I needed to pass the boolena value as a literal
string so I placed double quotes around the boolean value and single
quotes around the parameter.

onclick="ShowSpecifiedPeriod('<%If bShowPeriod = false then
Response.Write "true" else Response.Write "false"%>')"

Since you can't pass a "boolean value" on a URL at all (all you are
passing are the string "true" or the string "false" which then have
special meaning to the server-side processing), I usually pass either 0
or 1. It is shorter (if the resulting server request is a GET) and it is
much easier to deal with on the server (using server-side JavaScript in
this case):

var bShowPeriod = (1 == +Request.value('ShowPeriod'));
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top