0

I am having issues with this code, whenever the javascript can't find the value for the document.theform.Step<%=Session("checkno")%>.value it will not submit the form. On forms that have the value, there are no issues. Why would this code fail, as it checks whether or not the value exists?

Code for checking values upon form submission:

    var check940="<%=Session("check940")%>";
    var checkno="<%=Session("checkno")%>";
    if(document.theform.Step<%=Session("checkno")%>.value) {
    var check940current = document.theform.Step<%=Session("checkno")%>.value;
    if (check940=="yes" && check940current=="20")
    {
        alert("Test alert.");
    }
    }

Code for checking session variables and ensuring default value is assigned

<%
    If len(Session("check940")) <= 0 Then 
    Session("check940") = "no" 
    end if
    If len(Session("checkno")) <= 0 Then 
    Session("checkno") = "0" 
    end if
%>

When particular conditions are met, values are set to display alert in Javascript

                if (steparr(0,s)<>"20") and (docnum="940") then
                    Session("check940") = "yes"
                    Session("checkno") = d
                elseif (steparr(0,s)="20") and (docnum="940") then
                    Session("check940") = "no"
                    Session("checkno") = "0"
                end if
2
  • What does the actual JavaScript look like without all the serverside code? How does it fail, what is the error? Commented Apr 15, 2015 at 15:11
  • The firefox console comes up with "document.theform.step8 is undefined", so that's why I was trying to check if it's null Commented Apr 15, 2015 at 15:37

1 Answer 1

1

You are saying that "step8 is undefined" so you can not read the value of undefined. So your check

if(document.theform.Step<%=Session("checkno")%>.value) {

needs to drop the value.

if(document.theform.Step<%=Session("checkno")%>) {

Now you are just checking to see if the element is there before doing the next step.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.