2015-01-21 17 views
2

我有一個表單,當提交時將數據傳遞給taskqueue.php,然後繼續將值傳遞給process.php。如果在下拉列表中選擇了特定值,則GAE任務隊列將不會繼續

繼承人的下拉這就是導致問題:

<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> 

如果我選擇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> 
如果我改變下拉標籤

,世界上沒有問題,只是似乎本身就是價值。

我確實有隱藏/顯示下拉菜單的javascript,但我無法看到任何引用2014/2013的任何地方。

下面 FORM見代碼:

<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> 
    >? 

TASKQUEUE.PHP

<?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>"); 
    ?> 

任何你看到的可能是一個問題?在此先感謝,對於長期問題感到抱歉,必須確保我包括所有內容!

回答

0

找到了!

這是我的taskqueue.php AND processing.php中的$year變量,這是問題所在。改爲$yearend,似乎工作。希望這是它的結局!

0

所以看起來我忽略了style.css中存在另一個id'year'的事實。因此,所有我沒有在我的代碼改爲'year''yearend'

編輯: 所以將其更改爲「年底」,已經允許代碼迴路回到原來的頁面例如header("Location: /<another page>");不再給出空白頁面,但仍然不會在後臺處理任務,除非其'2015'。只是坐在任務隊列中。

相關問題