0

On one of my wordpress admin pages, I am building a form to add new mailers.

I have it checking the templates mysql table and building the list of available templates, then also giving it the option to add a new template.

for some reason, the form is not submitting. When I use chrome's console, I see it says syntax error unexpected } but I don't see a } anywhere in the HTML output on the page.

Here is my php that builds the form:

    <form action="http://somedomain.com/new-mailer" method="GET" name="form1"><hidden name="action" value="createANewMailer"><hidden name="then" value="customize"><?php
        $results = $wpdb->get_results($wpdb->prepare("SELECT * FROM `mailerTemplateFiles` where `u` = '1'"));
        $_MenuItem = "<select name=\"template\" required=\"1\" size=\"1\" autofocus>";
        foreach ($results as $res) {
            $_optv = $res->mtid;
            $_optl = $res->layoutname;
            $_MenuItem .= "<option value=\"$_optv\">" . $_optl . "</option>\n";
        }
        $_MenuItem .= "<option value=\"addNew\">Add New Template</option>";
        $_MenuItem .= "</select>";
        echo $_MenuItem;
    ?><input type="button" onclick="document.getElementById("form1").submit();" value="Continue"></form>

I have tried to just let it submit naturally by clicking the button, no onclick, but it did not work, so I added the onclick way to submit it. that does not work either.

Here is the HTML output it generates:

<form action="http://somedomain.com/new-mailer" method="GET" name="form1"><hidden name="action" value="createANewMailer"><hidden name="then" value="customize"><select name="template" required="1" size="1" autofocus><option value="addNew">Add New Template</option></select><input type="button" onclick="document.getElementById("form1").submit();" value="Continue"></form>

I don't see why it won't work.

-Rich

1 Answer 1

1

Your form does not contain an ID. You need to replace name="form1" with id="form1".

This is because your javascript says,

onclick="document.getElementById("form1").submit();" 

which returns False, because there is no form with the ID "form1".

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.