/    Sign up×
Community /Pin to ProfileBookmark

Messagebox prints out all no matter what

Hi

The first condition in red, in the function keeps printing out whether the condition is true or not – ie it prints out “you must select a date first” whether there is an active session called “left” or not.

How can I make it print this message [U]only[/U] if there is no session active called “left”. I am using ASP code, with a form activating the function later in the page, “onsubmit”.

Thanks

<script language=”JavaScript”>
function emptyselectbox1()
{
var messagebox = “”;

[COLOR=”Red”]if (“<%=Session(“left”)%>”!==true)
{
messagebox+= “You must select a date first n”;
}[/COLOR]

if (document.form3.checkIfClientEmpty.value.length<1)
{
messagebox+= “You must select a Client ID from the System first n”;
}

if (!(document.form3.select3.length>0))
{
messagebox += “There are no appointment times available n”;
}

if (document.form3.checkIfPatientEmpty.value.length<1)
{
messagebox+= “You must select a Patient ID from the System first n”;
}

if(messagebox.length>0)
{
alert(messagebox)
return false;
}
else
{
return true;
}
}
</script>

I also tried saving the session as a variable for javascript to use, like this

var messagebox = “”;

var thisID =”<%=Session(“left”)%>”

if (thisID!==true)
{
messagebox+= “You must select a date first n”;
}

but it still prints.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@sushiMar 17.2008 — is <%=Session("left")%> type boolean?

remember that !== is not equal to != or !=''.

You could alert('<%=Session("left")%>') to find out what it really is.
Copy linkTweet thisAlerts:
@sharon_annauthorMar 17.2008 — This is weird.

It is generating an empty alert - even if the session is active.

How can I change this to display only if the session truly isn't active.

Thanks
×

Success!

Help @sharon_ann spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...