我想用PHP获取表单ID。 这是我的HTML代码。问题中的每个答案都有一个ID。在PHP中获取HTML表单ID
<br><br><h3>Vraag 1: Wat is de juiste formule van Arbeid?</h3>
<input type="radio" name="question-1" id="question-1-A" value="2" />
<label for="question-1-A">A) Kracht (in Newton) keer Lengte (in meter) </label>
<input type="radio" name="question-1" id="question-1-B" value="0" />
<label for="question-1-B">B) Kracht keer Massa</label>
<input type="radio" name="question-1" id="question-1-C" value="0" />
<label for="question-1-C">C) Kracht keer valversnelling</label>
<input type="radio" name="question-1" id="question-1-D" value="0" />
<label for="question-1-D">D) Geen van deze antwoorden</label>
所以在PHP中,我得到的数值就是这样,计算得分:
$q1=$_POST['question-1'];
但我怎么能偷的ID,并让这个
if (*QUESTION-1-A* *IS FILLED IN*)
{
echo "You filled in A"
}
如何我要这样做吗?
您可以在'value'属性中传入'id' –
由于'id'仅在客户端可用,因此PHP无法工作。以这种方式用'id'操纵的最好方法是使用JavaScript而不是PHP。 – d3r1ck
你可以使用jquery获取id,然后通过ajax发送给php –