Zend Radio元素和Jquery选择器以获取ID和值

Zend Radio元素和Jquery选择器以获取ID和值,jquery,zend-framework,Jquery,Zend Framework,我使用Zend框架在html表单上显示收音机选项列表。我必须使用无线电元件 因为我想让用户看到页面上的所有选项,否则我会使用复选框。 我正在从数据库查询填充收音机列表 $sectorname = new Zend_Form_Element_Radio('sectorname'); $sectorname->setLabel('Sector'); $sectorname->setSeparator(' '); $sectorTable = new Model_DbTable_Secto

我使用Zend框架在html表单上显示收音机选项列表。我必须使用无线电元件 因为我想让用户看到页面上的所有选项,否则我会使用复选框。 我正在从数据库查询填充收音机列表

$sectorname = new Zend_Form_Element_Radio('sectorname');
$sectorname->setLabel('Sector');
$sectorname->setSeparator(' ');
$sectorTable = new Model_DbTable_Sector();
$sectors = $sectorTable->listSectors();
foreach($sectors as $sector)    
{
    $sectorname->addMultiOption($sector->id,$sector->name);
}
$sectorname->setDecorators($decors);
$this->addElement($sectorname);

$sectorid = new Zend_Form_Element_Hidden('sectorid');
$sectorid->setDecorators($decors);
$this->addElement($sectorid);
创建的html如下所示,您可以看到上面的扇区“id”和“name”映射到html中的标签值和输入“id”。还有一个隐藏的sectoridHTML元素

<tr>
<th>Sector</th>
<td>
<label for="sectorname-1"><input name="sectorname" id="sectorname-1" value="1" type="radio">Accountants</label>
<label for="sectorname-36"><input name="sectorname" id="sectorname-36" value="36" type="radio">Admin</label>
<label for="sectorname-2"><input name="sectorname" id="sectorname-2" value="2" type="radio">Agriculture</label>
<label for="sectorname-5"><input name="sectorname" id="sectorname-5" value="5" type="radio">Architects</label> 
<label for="sectorname-11"><input name="sectorname" id="sectorname-11" value="11" type="radio">Army</label>
<label for="sectorname-48"><input name="sectorname" id="sectorname-48" value="48" type="radio">Undefined</label></td>
<input name="sectorid" value="" id="sectorid" type="hidden">            
</tr>
我的问题是'sectorname'和'sectorid'元素都是数值。jquery有没有办法获取label元素的字符串值,并将其设置到表单中的隐藏元素上?

试试这个

$("#sectorid").val($(this).parent().text());

否-输入元素没有任何文本值。文本属于父标签元素。可能-但要获得接受,答案必须正确
$("#sectorid").val($(this).parent().text());