English 中文(简体)
在html中以不同名称建立动态控制
原标题:creating Dynamic controls in html with different names

I am creating radiobuttons in HTML .I am getting data from SQL Database.I am creating an attendence form in which there will be student name,Present Radio button ,Absent Radio button. I put the Present and Absent Radio button in a single Group,(so that only one could be clicked.The problem is that I can t create more than one radio group..My code is

<html>
<tr>
<td><?php echo $i;?></td> // Serial Number
<td> <label><?php echo $att[ std_name ];?></label></td> //student name
<td><input type="radio" name="std_r[]" id="std_r[]"></td> // for present
<td><input type="radio" name="std_r[]" id="std_c[]"></td> // for absent
<td><input type="hidden" value="<?php echo $att[ rollnum ];?>" > </td> //hidden field that will take roll number of student on next page

</tr>
</html>
<?php

I want that for each student there should be seperate group of radio buttons.thats why i want to create buttons with different name. Anyone who can help me with this Thanks

最佳回答

我猜测你要求的是,同一页上有数名学生,每个学生都有自己的现有/选择。

你应该这样做:

<input type="radio" name="test[1]" value="present" />
<input type="radio" name="test[1]" value="absent" />

<input type="radio" name="test[2]" value="present" />
<input type="radio" name="test[2]" value="absent" />

<input type="radio" name="test[3]" value="present" />
<input type="radio" name="test[3]" value="absent" />

You may also specific the student_id as index, this will be easier for you do handle in PHP:

<input type="radio" name="test[33888]" value="present" />
<input type="radio" name="test[33888]" value="absent" />

<input type="radio" name="test[90909]" value="present" />
<input type="radio" name="test[90909]" value="absent" />
问题回答

暂无回答




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签