2014-01-05 31 views
0

我有使用複選框上輸入形式,我稱他們爲作爲一個數組名稱=「好處[]」

這裝入一個jquery使用作爲Chain Selects的一部分。

我的問題是如何把陣列成爲準複選框被選中,我可以在另外的輸入框裏另一個網頁在我的網站中使用了$ _SESSION這樣呢?

<input type="checkbox" class="comOne" name="benefits[]" value="Pension credit" id="pension_credit" /> 
Pension credit 
<a href="#" class="showBenefitInfo" data-value="Pension credit is a top-up to the state pension and is a benefit that must be applied for if your state pension is below a certain amount.">[More...]</a> 

道歉,如果我不應該這樣做,不知道,如果你可以上傳一個文本框,反正這是代碼的複選框全款。如果需要,我可以粘貼整個表單。

      <div class="row"> 
           <div class="col-md-5"> 
            <label class="checkbox"> 
             <input type="checkbox" class="comOne" name="benefits[]" value="Pension credit" id="pension_credit" /> Pension credit <a href="#" class="showBenefitInfo" data-value="Pension credit is a top-up to the state pension and is a benefit that must be applied for if your state pension is below a certain amount.">[More...]</a> 
            </label> 
           </div> 
           <div class="col-md-5"> 
            <label class="checkbox"> 
             <input type="checkbox" class="comOne" rel="CTC" name="benefits[]" value="Child tax credit" id="child_tax_credit" /> Child tax credit <a href="#" class="showBenefitInfo" data-value="Child Tax Credit is a benefit that must be applied for, it is not the same as Child Benefit. An up-to-date Child Tax Credit award notice must be available to show the surveyor to proceed with your application. ">[More...]</a> 
            </label> 
           </div> 
          </div> 
          <div class="row"> 
           <div class="col-md-5"> 
            <label class="checkbox"> 
             <input type="checkbox" class="comOne" rel="ISJSA" name="benefits[]" value="Income support" id="income_support" /> Income support <a href="#" class="showBenefitInfo" data-value="Income support is a means-tested benefit and is primarily received by single parents with a child under 5.">[More...]</a> 
            </label> 
           </div> 
           <div class="col-md-6"> 
            <label class="checkbox"> 
             <input type="checkbox" class="comOne" rel="ISJSA" name="benefits[]" value="Job seekers allowance" id="job_seekers_allowance" /> Income based job seekers allowance <a href="#" class="showBenefitInfo" data-value="You must be in receipt of INCOME based job seekers allowance. This will be confirmed on your award notice (you will see printed on your letter: 'This assessment is based on how much the law says you need to live on').">[More...]</a> 
            </label> 
           </div> 
          </div> 
          <div class="row"> 
           <div class="col-md-5"> 
            <label class="checkbox"> 
             <input type="checkbox" class="comOne" rel="WTC" name="benefits[]" value="Working tax credit" id="working_tax_credit" /> Working tax credit <a href="#" class="showBenefitInfo" data-value="You will need to have you Working Tax Credit award notice available (this will be the same as Child Tax Credit award notice if both are being received). Page 2 and 3 will confirm your household income and this MUST be less than &pound;15,860 to qualify.">[More...]</a> 
            </label> 
           </div> 
           <div class="col-md-6"> 
            <label class="checkbox"> 
             <input type="checkbox" class="comOne" rel="ESA" name="benefits[]" value="Income related employment" id="income_related" /> Income related employment and support allowance <a href="#" class="showBenefitInfo" data-value="Also known as ESA, Employment and Support Allowance must be INCOME related and NOT contribution based. This will be confirmed on your ESA award notice.">[More...]</a> 
            </label> 
           </div> 
          </div> 
          <div class="row"> 
           <hr> 
            <div class="col-md-12"> 
             <label class="checkbox"> 
              <input type="checkbox" class="comOne" name="benefits[]" value="I do NOT receive any of the above benefits" id="no_benefits" /> I do NOT receive any of the above benefits 
             </label> 
            </div> 
           </hr> 
          </div> 
+0

如果有多個複選框這將是最好使用指數,以及準確地識別哪些複選框被選中,即'「NAME =效益[]「'。 –

+0

所以使用了一些如姓名=「benfits [1]」等,或使用在輸入也可以作爲一個例子,我有「ID =」 pension_credit」所以用名字=效益‘[pension_credit] id爲’?還會怎麼樣恰巧這樣做的jQuery使用效益[],看看使用哪個複選框? – Jez

回答

1

這是很簡單的:

$_SESSION['benefits'] = $_POST['benefits']; 
+0

謝謝,我想,第一次發佈之前,這是我有我的網頁我希望它在輸入框中顯示的是什麼,它在返回數組我 – Jez

+0

其他頁面上輸入框難道你把'在session_start()'在所有要上使用會話頁面的頂部這會阻止這樣做的唯一的事情 –

+0

是所有頁面開始在session_start()?。 – Jez