2

I'm just starting to use JQuery, and I'm editing the modal popup example within a classic asp page. I've gotten the form to work, and added a submit line, but after the submit I try to get the submitted values with asp using request.form("email") but it's coming up blank.

Is this a problem with how I'm submitting, how I'm reading the values, or something else? What do I need to do to submit the form and get the values?

Here's the code:

I call the dialog with this:

<strong>Forgot your login?:</strong> <a href="#" id="send-password">click here</a></p>

The dialog form:

<div id="dialog-form" title="Send My Login">
        Enter the email address associated with your account. Your password will be sent to you.
        <br />
        <strong>If you do not have an email address</strong>, or do not 
        remember it, please contact your Human Resources department to have your login 
        provided to you.

        <p class="validateTips">

         </p>

        <form action="SendLogin.asp" method="Post" name="modalPopup">
        <fieldset>

            <label for="email">Email</label>
            <input type="text" name="email" id="email" value="" class="text ui-widget-content ui-corner-all" />

        </fieldset>
        </form>
    </div>

The dialog code:

<script type="text/javascript">

    $(function () {

        //Modal pop-up form
        // a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
        $("#dialog:ui-dialog").dialog("destroy");

        var email = $("#email"),
                allFields = $([]).add(email);
                tips = $(".validateTips");

        function updateTips(t) {
            tips
                    .text(t)
                    .addClass("ui-state-highlight");
            setTimeout(function () {
                tips.removeClass("ui-state-highlight", 1500);
            }, 500);
        }

        function checkLength(o, n, min, max) {
            if (o.val().length > max || o.val().length < min) {
                o.addClass("ui-state-error");
                updateTips("Length of " + n + " must be between " +
                        min + " and " + max + ".");
                return false;
            } else {
                return true;
            }
        }

        function checkRegexp(o, regexp, n) {
            if (!(regexp.test(o.val()))) {
                o.addClass("ui-state-error");
                updateTips(n);
                return false;
            } else {
                return true;
            }
        }

        $("#dialog-form").dialog({
            autoOpen: false,
            height: 350,
            width: 350,
            modal: true,
            buttons: {
                "Send Login": function () {
                    var bValid = true;
                    allFields.removeClass("ui-state-error");

                    bValid = bValid && checkLength(email, "email", 5, 80);

                    // From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
                    bValid = bValid && checkRegexp(email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "Please enter a valid email address.");

                    if (bValid) {
                        $("#users tbody").append("<tr>" +
                                "<td>" + email.val() + "</td>" +
                            "</tr>");
                        $(this).dialog("close");
                        $("form[name='modalPopup']").submit()

                    }

                },
                Cancel: function () {
                    $(this).dialog("close");
                }
            },
            close: function () {
                allFields.val("").removeClass("ui-state-error");
            }
        });

        $("#send-password")

                .click(function () {
                    $("#dialog-form").dialog("open");
                });


    });
</script>

The form is submitted to SendLogin.asp and I try to receive the value with this:

<%tempEmail=request.form("email")%>

But tempEmail is coming up blank when I try to print it afterward. What do I need to do to get the submitted form values?

Any help is appreciated!

Cineno28
  • 889
  • 1
  • 22
  • 41
  • Are you sure there is a value in `request.form("email")` and that the form is being submitted? – jk. Mar 06 '12 at 02:06
  • @jk Well, the form dialog's action is SendLogin.asp, and when I added the submit line it I'm definitely directed to SendLogin.asp so I thought the form was submitting properly. But then on SendLogin.asp I have the request.form("email) and it's coming up blank as if there's no value in it. Thanks for the response, any ideas what I should do? – Cineno28 Mar 06 '12 at 02:10

1 Answers1

0

Try changing your submit to this:

document.modalPopup.submit();
jk.
  • 14,365
  • 4
  • 43
  • 58
  • Thanks for the suggestion. I tried that, but I'm still ending up with a blank value for my request.form("email"). Really not sure why it's not coming through – Cineno28 Mar 06 '12 at 02:27
  • For some reason it's working now, haha. I had tried that before but it wasn't coming through, and now it is. Not sure what else I changed, but the line you suggested is definitely submitting the form, so thanks for the help! – Cineno28 Mar 06 '12 at 20:13
  • @Cineno28 Great! You're welcome. I tried submitting the form on a test page in the manner you had it and couldn't get it to work. However, `document.modalPopup.submit();` did work. That's why I thought the form wasn't submitting properly in the first place and offered the alternative submit. – jk. Mar 06 '12 at 20:19