Javascript Web Crawler确认确认框

时间:2018-02-04 22:16:40

标签: javascript jquery html web-crawler

我正在尝试在Javascript中为学校项目确认一个确认框。出现确认框询问您是否要提交,我想以编程方式提交。以下是表单的HTML:

<form action="https://weekend.lps.wels.net/lpswp/index.php" method="post" id="form_wp_entry" onsubmit="return lpswp_confirm_submission('3,4','Friday,Saturday','Sunday')" style="display: inline;">
                        <table class="em_table" width="100%" style="margin-bottom: 5px;">

                            <tbody><tr>
                                <th align="left" id="lpswp_night_label_title_3">
                                    Friday
                                </th>
                            </tr>
                            <tr>
                                <td>

                                    Location: <input type="radio" name="lpswp_nights[3][location]" id="lpswp_nights_location_dorm_3" value="dorm" checked="checked" onclick="lpswp_toggle_location(3)"> <label for="lpswp_nights_location_dorm_3">Dorm</label> |
                                    <input type="radio" name="lpswp_nights[3][location]" id="lpswp_nights_location_home_3" value="home" onclick="lpswp_toggle_location(3)"> <label for="lpswp_nights_location_home_3">Home</label><br>
                                    <input type="radio" name="lpswp_nights[3][location]" id="lpswp_nights_location_other_3" value="other" onclick="lpswp_toggle_location(3)"> <label for="lpswp_nights_location_other_3" id="lpswp_night_label_text_3">Other</label>: 
                                    <input type="text" size="60" name="lpswp_nights[3][other]" id="lpswp_nights_other_3"><br>
                                    Phone Number (if known): <input type="text" size="20" name="lpswp_nights[3][phone]" id="lpswp_nights_phone_3"> (999-999-9999)
                                </td>
                            </tr>

                            <tr>
                                <th align="left" id="lpswp_night_label_title_4">
                                    Saturday
                                </th>
                            </tr>
                            <tr>
                                <td>
                                    <input type="checkbox" name="lpswp_nights[4][same]" id="lpswp_nights_same_4" value="1" checked="checked" onclick="lpswp_toggle_same(4)"> <label for="lpswp_nights_same_%temp_night%">Same as Friday night.</label><br>
                                    Location: <input disabled="disabled" type="radio" name="lpswp_nights[4][location]" id="lpswp_nights_location_dorm_4" value="dorm" checked="checked" onclick="lpswp_toggle_location(4)"> <label for="lpswp_nights_location_dorm_4">Dorm</label> |
                                    <input disabled="disabled" type="radio" name="lpswp_nights[4][location]" id="lpswp_nights_location_home_4" value="home" onclick="lpswp_toggle_location(4)"> <label for="lpswp_nights_location_home_4">Home</label><br>
                                    <input disabled="disabled" type="radio" name="lpswp_nights[4][location]" id="lpswp_nights_location_other_4" value="other" onclick="lpswp_toggle_location(4)"> <label for="lpswp_nights_location_other_4" id="lpswp_night_label_text_4">Other</label>: 
                                    <input disabled="disabled" type="text" size="60" name="lpswp_nights[4][other]" id="lpswp_nights_other_4"><br>
                                    Phone Number (if known): <input disabled="disabled" type="text" size="20" name="lpswp_nights[4][phone]" id="lpswp_nights_phone_4"> (999-999-9999)
                                </td>
                            </tr>

                            <tr>
                                <th align="left" id="lpswp_final_dinner_label_title">
                                    Sunday Dinner
                                </th>
                            </tr>
                            <tr>
                                <td id="lpswp_final_dinner_label_text" style="border: 0px;">
                                    I WILL be eating in the cafeteria: <input type="radio" name="lpswp_final_dinner" id="lpswp_final_dinner_1" value="1"><br>
                                    I will NOT be eating in the cafeteria: <input type="radio" name="lpswp_final_dinner" id="lpswp_final_dinner_0" value="0"><br>
                                    <input type="hidden" name="lpswp_final_dinner_night" value="5">
                                </td>
                            </tr>
                        </tbody></table>
                    <input type="submit" value="Submit Weekend Plans">
                    <!--input type="reset" value="Cancel" /-->
                    </form>

这是我当前的代码,它对确认框没有任何作用:

mWebView.loadUrl("javascript:(function(){" +
                            "document.getElementById('form_wp_entry').setAttribute('onsubmit','return true;');" +
                            ";})()");

请帮助我,我是javascript的新手......以及一般的编码。

1 个答案:

答案 0 :(得分:1)

您正在寻找 the hello_world.py from bcc
请注意,这不会触发任何与相关联的功能表格的.submit()

&#13;
&#13;
function output() {
  console.log('Submitted');
  return false;
}

// Forcibly submit the form
function customSubmit() {
  document.getElementsByTagName('form')[0].submit();
}
&#13;
<form name="a_form" onsubmit="return output()">
  <button type="submit">Submit</button>
</form>
<br />
<button onclick="customSubmit()">Submit Programmatically</button>
&#13;
&#13;
&#13;

希望这有帮助!