Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Pass Boolean Parameter to JS Function

Reply
Thread Tools

Pass Boolean Parameter to JS Function

 
 
Matt
Guest
Posts: n/a
 
      07-18-2005
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.

 
Reply With Quote
 
 
 
 
Ray Costanzo [MVP]
Guest
Posts: n/a
 
      07-18-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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.


 
Reply With Quote
 
 
 
 
Aaron Bertrand [SQL Server MVP]
Guest
Posts: n/a
 
      07-18-2005
Try:

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

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



"Matt" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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.


 
Reply With Quote
 
Steven Burn
Guest
Posts: n/a
 
      07-18-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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.


 
Reply With Quote
 
Aaron Bertrand [SQL Server MVP]
Guest
Posts: n/a
 
      07-18-2005
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:%(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) 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.
>
>



 
Reply With Quote
 
Matt
Guest
Posts: n/a
 
      07-18-2005
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Subtle difference between boolean value and boolean comparison? Metre Meter Javascript 7 08-06-2010 08:40 PM
How to pass a parameter for a function parameter in a function AzamSharp Javascript 2 07-05-2008 12:24 AM
difference between 'boolean' and 'java.lang.Boolean' J Leonard Java 4 01-19-2008 02:56 AM
Boolean Function Parameter Matt Javascript 2 07-25-2005 07:27 PM
write a function such that when ever i call this function in some other function .it should give me tha data type and value of calling function parameter komal C++ 6 01-25-2005 11:13 AM



Advertisments