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

1 回答 1

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">
于 2013-04-16T10:21:37.583 回答