2013-04-16 42 views
0

我想添加一個提交或保存按鈕,將客戶答案添加到數據庫表'通訊'。任何人都知道如何去做這件事?客戶已經登錄了其他細節以添加到表格中,我可以自己弄清楚。時事通訊首選項 - 添加到數據庫

<div id="newsletter-settings"> 
           <h3 style="margin-left:0; padding:0; font-size:14px; background:none; margin:0;">Your Newsletter Settings</h3> 
           <p>You can edit your newsletter preferences by checking the boxes below to suit your requirements.</p> 

           <form method="post"> 
            <label for="recieve-newsletter">Do you wish to receive the Make A Will Now email newsletter?</label> 
            <input type="radio" name="recieve-newsletter" value="Yes" /><span>Yes</span> 
            <input type="radio" name="recieve-newsletter" value="No" style="margin-left:20px;" /><span>No, not at the moment</span> 

            <label for="newsletter-partners" style="margin-top:20px;">Do you wish to receive emails from carefully selected partners?</label> 
            <input type="radio" name="newsletter-partners" value="Yes" /><span>Yes</span> 
            <input type="radio" name="newsletter-partners" value="No" style="margin-left:20px;" /><span>No, not at the moment</span> 
           </form> 
          </div> 
+0

你在使用mysql數據庫嗎?你有沒有在你的頁面連接數據庫,你只需要查詢? – Mhche

+0

是的,是的。 –

+0

在表格簡報中,您只存儲客戶的答案? – Mhche

回答

1

那麼你可以得到檢查按鈕與jQuery值:

var val = $('input:radio[name=recieve-newsletter]:checked').val(); 

那麼你可以說你的提交按鈕,你的數據庫有了這樣的功能,插入了答案:

function insert(){ mysql_query("insert into newsletter (answer) values ('$val')");} 

現在該按鈕會像

<input type="submit" OnClick="insert();" value="submit your answer">