problem with simple if statement

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • andersond
    New Member
    • Feb 2007
    • 110

    problem with simple if statement

    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?

    Code:
    <p>		              
                      <input type="text" name="status" id="status" size="20" tabindex="-1">
                      </p>
    
    if (document.screenTwo.nearH2O[0].checked==true) { // NO
        				document.getElementById('nearWater').value="NO";
        				document.getElementById('cellOutput02').innerHTML="Property is not located within 10 miles of an ocean, bay, or waterway";
        				document.getElementById('response2').value="Property is not located within 10 miles of an ocean, bay, or waterway";
        			} else if (document.screenTwo.nearH2O[1].checked==true) { // YES
        				document.getElementById('nearWater').value="YES";
        				document.getElementById('status').value ="REFERRED";
        				document.getElementById('cellOutput02').innerHTML="Property is located within 10 miles of an ocean, bay or waterway";
        				document.getElementById('response2').value="Property is located within 10 miles of an ocean, bay, or waterway";
        				var issue = "Property is located within 10 miles of an ocean, bay, intercostal waterway";
        				if(document.getElementById('issue1').value==""){
        					document.getElementById('issue1').value = issue;
        				} else if(document.getElementById('issue2').value==""){
        					document.getElementById('issue2').value = issue;
        				}
        			}
  • Delerna
    Recognized Expert Top Contributor
    • Jan 2008
    • 1134

    #2
    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?

    [code=jscript]
    document.getEle mentById('statu s').value ="REFERRED";
    alert(document. getElementById( 'status').value );

    [/code]

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Look for any other "status" -named or ID in your HTML.

      Comment

      Working...