By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,934 Members | 1,366 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,934 IT Pros & Developers. It's quick & easy.

Pass Boolean Parameter to JS Function

P: n/a
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(pShowPerio*d){
document.mfperformance.ShowPer*iod.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(pShowPerio*d boolean) - Same Error
Please let me know what I am doing wrong here. Thanks.

Jul 22 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Javascript is case sensitive. Since you're telling VBScript to
Response.Write True or False, it will write it as it seems fit -
capitalized. Use literal strings when you Response.Write stuff:

<% If bShowPeriod Then Response.Write "false" Else Response.Write "true" %>

Do you really mean to have "If true then false, and if false then true?"

Ray at work
"Matt" <ma***********@manning-napier.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
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(pShowPerio*d){
document.mfperformance.ShowPer*iod.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(pShowPerio*d boolean) - Same Error
Please let me know what I am doing wrong here. Thanks.
Jul 22 '05 #2

P: n/a
Try:

onclick="ShowSpecifiedPeriod('<%= not bShowPeriod %>');"

Note the quotes around the value. Otherwise, JS will expect a variable name
(which you have not defined)...

"Matt" <ma***********@manning-napier.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
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(pShowPerio*d){
document.mfperformance.ShowPer*iod.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(pShowPerio*d boolean) - Same Error
Please let me know what I am doing wrong here. Thanks.
Jul 22 '05 #3

P: n/a
onclick="ShowSpecifiedPeriod('<*%If bShowPeriod = false then
Response.Write "true" else Response.Write "false"%>')"

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

::: Declaration :::

Ur I.T. Mate Group is NOT a company, it is a non-commercial and not for
profit collection of websites developed and maintained by Steven Burn.

Websites and domains currently owned by Ur I.T. Mate Group are provided on a
free to view and use basis. Ur I.T. Mate Group does not and will not ask for
or solicit, personal information*, password, credit card details or
payments. For more information, please see our Privacy Policy.

Ur I.T. Mate Group and Steven Burn (CEO) are based in the United Kingdom.

* Except where registration for an online service is required (e.g. forums,
sGB)

"Matt" <ma***********@manning-napier.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
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(pShowPerio*d){
document.mfperformance.ShowPer*iod.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(pShowPerio*d boolean) - Same Error
Please let me know what I am doing wrong here. Thanks.
Jul 22 '05 #4

P: n/a
Of course, I was thinking about the wrong set of quotes, not the case
sensitivity...

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:%2****************@TK2MSFTNGP14.phx.gbl...
Javascript is case sensitive. Since you're telling VBScript to
Response.Write True or False, it will write it as it seems fit -
capitalized. Use literal strings when you Response.Write stuff:

<% If bShowPeriod Then Response.Write "false" Else Response.Write "true"
%>

Do you really mean to have "If true then false, and if false then true?"

Ray at work
"Matt" <ma***********@manning-napier.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
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(pShowPerio*d){
document.mfperformance.ShowPer*iod.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(pShowPerio*d boolean) - Same Error
Please let me know what I am doing wrong here. Thanks.

Jul 22 '05 #5

P: n/a
Great. Thank you very much. Using the literal string worked great. Yes
I do want if true then false and if false then true. I want the button
option to be different than the actual option. Otherwise when the user
invokes the onClcik event I will always be passing the same boolean
value. The JS function will submit the form and the "ShowPeriod" is a
hidden form field that I use. Initially the screen will not paint a
portion until the user clicks the biton to show the remainder of the
screen. Then if they also need to ability to hide it. Thanks.

I did try with the single quotes (around the parameter) and without
them before but it was the double quotes around the true and false that
did.

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

Thank you very much for your posts.

Jul 22 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.