By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,377 Members | 1,660 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,377 IT Pros & Developers. It's quick & easy.

problem with simple if statement

P: 110
Most of the code below is just included so I could use a cut and paste to assure that everything was being presented completely. The script executes perfectly except for the line where it is to set the status field to "REFERRED". This is from a form containing 31 questions. Each question has the potential to cause the submission to be referred rather than quoted. The script ignores that command on every question; so, I have included the html line that contains the field, "status." It used to work. Now it doesn't. Can anybody figure out what is wrong?

Expand|Select|Wrap|Line Numbers
  2. <p>                      
  3.                   <input type="text" name="status" id="status" size="20" tabindex="-1">
  4.                   </p>
  6. if (document.screenTwo.nearH2O[0].checked==true) { // NO
  7.                     document.getElementById('nearWater').value="NO";
  8.                     document.getElementById('cellOutput02').innerHTML="Property is not located within 10 miles of an ocean, bay, or waterway";
  9.                     document.getElementById('response2').value="Property is not located within 10 miles of an ocean, bay, or waterway";
  10.                 } else if (document.screenTwo.nearH2O[1].checked==true) { // YES
  11.                     document.getElementById('nearWater').value="YES";
  12.                     document.getElementById('status').value ="REFERRED";
  13.                     document.getElementById('cellOutput02').innerHTML="Property is located within 10 miles of an ocean, bay or waterway";
  14.                     document.getElementById('response2').value="Property is located within 10 miles of an ocean, bay, or waterway";
  15.                     var issue = "Property is located within 10 miles of an ocean, bay, intercostal waterway";
  16.                     if(document.getElementById('issue1').value==""){
  17.                         document.getElementById('issue1').value = issue;
  18.                     } else if(document.getElementById('issue2').value==""){
  19.                         document.getElementById('issue2').value = issue;
  20.                     }
  21.                 }
Mar 18 '09 #1
Share this Question
Share on Google+
2 Replies

Expert 100+
P: 1,134
looks fine to me
have you tried putting an alert after the line in question so you can see if the code is actually getting past that line and that it has been set correctly?

Maybe it is getting reset elsewhere?
Or maybe the else if isnt returning true?
Or maybe something else?

Expand|Select|Wrap|Line Numbers
  1. document.getElementById('status').value ="REFERRED"; 
  2. alert(document.getElementById('status').value);
Mar 18 '09 #2

Expert Mod 15k+
P: 16,027
Look for any other "status" -named or ID in your HTML.
Mar 19 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.