?
Solved

document

Posted on 2006-04-06
3
Medium Priority
?
142 Views
Last Modified: 2013-12-24
Why isn't this working?
I'm passing a value in from a hidden field, which would be
document.linkk.lockedAppt.value.

The alert "Going through" shows ups

However the alert message test and test2 never show up.
function getLockedAppt()
      {      
            alert('going through!');
      
            var lockVar=document.linkk.lockedAppt.value;
            alert(lockVar);
            if (lockVar=="false")
            {
                  alert('test');      
            }
            else
            {
                  alert('test2');
            }      
      }
0
Comment
Question by:djb80
  • 2
3 Comments
 
LVL 10

Expert Comment

by:rob_lorentz
ID: 16393936
java script is case sensitive.make sure the if (lockVar=="" statement matches the first alert. Including spaces. you might want to add a trim setting lockVar.
0
 
LVL 4

Expert Comment

by:Ike23
ID: 16393962
Are you sure the actual value of the form field is "false"?  If you are checking to see if it is blank then try this:

if (lockVar=="")

Or it could be that you have alert(lockVar); before the if statement and if it is false that might be stopping the function from moving into the if...

Try commenting out the alert(lockVar); before the if statement and see what happens.

Cheers!
0
 
LVL 10

Accepted Solution

by:
rob_lorentz earned 2000 total points
ID: 16394112
the javaScript must be defined after the form. example

<form action="this.html" method="post" name="testForm">
      <input type="text" value="false" name="linkk" id="linkk">
</form>
<script language="JavaScript">
   alert('going through!');
      var lockVar=document.testForm.linkk.value;
          alert(lockVar);
          if (lockVar=="false")
          {
               alert('test');    
          }
          else
          {
               alert('test2');
          }    
 
</script>
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Loops Section Overview
Suggested Courses
Course of the Month13 days, 14 hours left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question