473,398 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Boolean Function Parameter

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.

Jul 23 '05 #1
2 13257
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"%>')"

Jul 23 '05 #2
"Matt" <ma***********@manning-napier.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
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'));

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 25 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Eyal | last post by:
Hey, I would appriciate if anyone can help on this one: I have a java object/inteface having a method with a boolean parameter. As I'm trying to call this method from a javascript it fails on...
5
by: Matt | last post by:
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. ...
4
by: MLH | last post by:
The following function declaration confuses me... Public Function IsEMailAddress(ByVal sEmail As String, Optional ByRef sReason As String) As Boolean I tried pasting it and its code into an...
8
by: Metro Sauper | last post by:
Why is the default text representation for booleans in C# 'True' and 'False' whereas in xml it is 'true' and 'false'? It seems like it would make sense to have them both the same. Metro T....
10
by: dba123 | last post by:
Why am I getting this error for Budget? Error: An exception of type 'System.FormatException' occurred in mscorlib.dll but was not handled in user code Additional information: String was not...
4
by: Joe HM | last post by:
Hello - I realize that there is no more IsMissing function in VB.NET but how can I have a boolean argument that is optional and in the code I need to determine whether it was passed it or not? ...
2
by: John | last post by:
My application needs to call Oracle function using oracle client 9.2. The oracle function returns boolean value from its returned parameter. The name space that I used is system.data.oracleclient....
10
by: Zoe Hart | last post by:
I have a wsdl file that I received from a third party and I'm using wsdl.exe (.NET 2.0) to import it and generate a proxy class. I've actually got a proxy class that works, but I'm trying to...
2
by: jobs | last post by:
What's messed up here is that i have close to identical code that is working perfectly, only difference is that code uses sqldatasource control instead objectdatasource used here. Getting this...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.