• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 143
  • Last Modified:

document

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
djb80
Asked:
djb80
  • 2
1 Solution
 
rob_lorentzCommented:
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
 
Ike23Commented:
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
 
rob_lorentzCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now