【发布时间】:2011-06-02 11:58:54
【问题描述】:
我有一个名为 patient_id 的隐藏表单字段,我需要使用 jquery 进行设置。我使用以下代码以及另外 2 个字段来设置它:
$('#investigation_patient_id').val($('#patient_id').html());
$('#patient_first_name').val($('#patient_fname').html());
$('#patient_last_name').val($('#patient_sname').html());
当我对 $('#investigation_patient_id') 发出警报时,它会提醒正确的值。虽然当我在设置后检查 firebug 中的字段时,没有 value 属性,更不用说它的值了。但是当我检查上面设置的其他字段时,它们的值是正确的。
当我提交表单时,然后做一个 die 声明:
die($request->getPostParameter("investigation[patient_id]"));
die 语句是空白的,但如果我在我设置的其他表单字段中死亡,它们会显示出来。 $request 的 print_r 也显示 Patient_id 的值为空。
那么发生了什么?为什么我不能设置隐藏表单域?
【问题讨论】:
-
您能否将给定字段的一些生成的 html 添加到您的问题中?
-
你确定你的 js 代码已经运行,并且在正确的时刻运行了吗?