Javascript 如果选择了下拉列表中的特定值,GAE任务队列将不会继续
我有一个表单,提交时将数据传递到taskqueue.php,然后taskqueue.php将值传递到process.php 以下是导致问题的下拉列表:Javascript 如果选择了下拉列表中的特定值,GAE任务队列将不会继续,javascript,php,google-app-engine,drop-down-menu,task-queue,Javascript,Php,Google App Engine,Drop Down Menu,Task Queue,我有一个表单,提交时将数据传递到taskqueue.php,然后taskqueue.php将值传递到process.php 以下是导致问题的下拉列表: <select id="year" name='year'> <option value="0">Year End...*</option> <option value="2013">2013</option> <option value="2014">2014</op
<select id="year" name='year'>
<option value="0">Year End...*</option>
<option value="2013">2013</option>
<option value="2014">2014</option>
<option value="2015">2015</option>
</select>
年底*
2013
2014
2015
如果我选择2015,无问题,它将继续进入taskqueue.php,然后进入processing.php并执行任务。如果我选择2014年或2013年,那么我会得到一个空白页面,其url看起来像是卡在taskqueue.php上
如果我将下拉列表中的所有“值”更改为2015年,那么它将继续处理任务,例如
<option value="2015">2013</option>
<option value="2015">2014</option>
<option value="2015">2015</option>
2013
2014
2015
如果我更改下拉标签,没有问题,只是看起来值本身
我确实有javascript可以隐藏/显示下拉列表,但我看不到任何地方特别提到2014/2013
请参阅下面的代码
表格:
功能显示_字段(e){
document.getElementById('month').style.display=“无”;
document.getElementById('quarter').style.display=“无”;
document.getElementById('year').style.display=“无”;
periodend=document.getElementById('periodend')。值;
如果(periodend==‘Monthly’){
document.getElementById('year')。selectedIndex=0;
document.getElementById('month').style.display=“inline”;
document.getElementById('year').style.display=“inline”;
document.getElementById('quarter')。selectedIndex=0;
}
如果(periodend=='Quarterly'){
document.getElementById('year')。selectedIndex=0;
document.getElementById('quarter').style.display=“inline”;
document.getElementById('year').style.display=“inline”;
document.getElementById('month')。selectedIndex=0;
}
如果(periodend==‘每年’){
document.getElementById('year')。selectedIndex=0;
document.getElementById('year').style.display=“inline”;
document.getElementById('month')。selectedIndex=0;
document.getElementById('quarter')。selectedIndex=0;
}
}
函数验证(){
periodend=document.getElementById('periodend')。值;
月份=document.getElementById('month')。值;
季度=document.getElementById('quarter')。值;
年份=document.getElementById('year')。值;
如果(periodend=='0'| |(periodend=='0'| | | |年=='0'))| |(periodend=='Quarterly'和&(quarter=='0'| | |年=='0'))|(periodend=='year'年=='0')){
有效警报=“”;
如果(周期结束=='0'){
有效\u alert='请选择期间结束\n';
}
如果(periodend=='Monthly'&&(month=='0'| | year=='0')){
如果(月份=='0'){
valid_alert=valid_alert+'请选择月末\n';
}
如果(年份=='0'){
valid_alert=valid_alert+'请选择一年\n';
}
}
如果(周期结束=='季度'&(季度=='0'| |年=='0')){
如果(四分之一=='0'){
valid_alert=valid_alert+“请选择一个季度末\n”;
}
如果(年份=='0'){
valid_alert=valid_alert+'请选择一年\n';
}
}
如果(周期结束=='year'&&year=='0'){
valid_alert=valid_alert+'请选择一年\n';
}
警报(有效警报);
返回false;
}否则{
返回true;
}
}
你看到的任何东西都可能是个问题吗?提前谢谢,很抱歉这个冗长的问题,我必须确保我包括了所有内容 看来我忽略了一个事实,在我的style.css中还有一个id“year”。因此,我所做的只是将代码中的
'year'
更改为'yearend'
编辑:
因此,将其更改为“yearend”,允许代码循环回原始页面,例如标题(“位置:/”代码>不再提供空白页,但仍然不会在后台处理任务,除非是“2015”。就在任务队列中。找到了
问题出在我的taskqueue.php和processing.php中的$year
变量。将其更改为$yearend
,似乎有效。希望就这样结束了
<script type="text/javascript" language="javascript">
function display_Field(e){
document.getElementById('month').style.display = "none";
document.getElementById('quarter').style.display = "none";
document.getElementById('year').style.display = "none";
periodend=document.getElementById('periodend').value;
if (periodend === 'Monthly') {
document.getElementById('year').selectedIndex = 0;
document.getElementById('month').style.display = "inline";
document.getElementById('year').style.display = "inline";
document.getElementById('quarter').selectedIndex = 0;
}
if(periodend === 'Quarterly') {
document.getElementById('year').selectedIndex = 0;
document.getElementById('quarter').style.display = "inline";
document.getElementById('year').style.display = "inline";
document.getElementById('month').selectedIndex = 0;
}
if (periodend === 'Yearly'){
document.getElementById('year').selectedIndex = 0;
document.getElementById('year').style.display = "inline";
document.getElementById('month').selectedIndex = 0;
document.getElementById('quarter').selectedIndex = 0;
}
}
function validate() {
periodend=document.getElementById('periodend').value;
month=document.getElementById('month').value;
quarter=document.getElementById('quarter').value;
year=document.getElementById('year').value;
if (periodend==='0'||(periodend==='Monthly' && (month==='0'||year==='0'))||(periodend==='Quarterly' && (quarter==='0'||year==='0'))||(periodend==='Yearly' && year==='0')) {
valid_alert='';
if (periodend==='0') {
valid_alert='Please select a period end\n';
}
if (periodend==='Monthly' && (month==='0'||year==='0')) {
if (month==='0') {
valid_alert=valid_alert+'Please select a month end\n';
}
if (year==='0') {
valid_alert=valid_alert+'Please select a year\n';
}
}
if (periodend==='Quarterly' && (quarter==='0'||year==='0')) {
if (quarter==='0') {
valid_alert=valid_alert+'Please select a quarter end\n';
}
if (year==='0') {
valid_alert=valid_alert+'Please select a year\n';
}
}
if (periodend==='Yearly' && year==='0') {
valid_alert=valid_alert+'Please select a year\n';
}
alert(valid_alert);
return false;
} else {
return true;
}
}
</script>
<?php
<form id="report-form" name="report-form" action="/taskqueue.php" method="post" style="margin-bottom:40px;">
<select id="periodend" name="periodend" class="inline" onChange="display_Field(this.selectedIndex);">
<option value="0">Period Ended...*</option>
<option value="Monthly">Monthly</option>
<option value="Quarterly">Quarterly</option>
<option value="Yearly">Yearly</option>
</select>
<select id="month" name='month'>
<option value="0">Month End...*</option>
<option value="January">January</option>
<option value="February">February</option>
<option value="March">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June">June</option>
<option value="July">July</option>
<option value="August">August</option>
<option value="September">September</option>
<option value="October">October</option>
<option value="November">November</option>
<option value="December">December</option>
</select>
<select id="quarter" name='quarter'>
<option value="0">Quarter End...*</option>
<option value="30 September">30 September</option>
<option value="31 December">31 December</option>
<option value="31 March">31 March</option>
<option value="30 June">30 June</option>
</select>
<select id="year" name='year'>
<option value="0">Year End...*</option>
<option value="2013">2013</option>
<option value="2014">2014</option>
<option value="2015">2015</option>
</select>
<input type="submit" id="save-submit" name="save-submit" value="Save & Setup Another" onClick="return validate();"></form>
>?
<?php
require_once 'google/appengine/api/taskqueue/PushTask.php';
use google\appengine\api\taskqueue\PushTask;
$name=$current_user->businessname;
$staff_member=$current_user->user_firstname." ".$current_user->user_lastname;
$staff_email=$user_email;
$client_name=stripslashes($_POST['search']);
$periodend=$_POST['periodend'];
$month=$_POST['month'];
$quarter=$_POST['quarter'];
$year=$_POST['year'];
$comments=$_POST['comments'];
$setupanother=$_POST['save-submit'];
$submit=$_POST['submit'];
if($_POST['save-submit'] || $_POST['submit']){
$wp_task = new PushTask('/process.php', ['name' => $name
, 'staff_member' => $staff_member
, 'client_name' => $client_name
, 'staff_email' => $staff_email
, 'periodend' => $periodend
, 'month' => $month
, 'quarter' => $quarter
, 'year' => $year
, 'comments' => $comments
, 'save-submit' => $setupanother
, 'submit' => $submit
]);
$task_name = $wp_task->add();
}
header("Location: /<another page>");
?>