[英]web2py How to add id to submit_button
In my html file, I'm adding two forms, each with their own submit_button. 在我的html文件中,我添加了两种形式,每种形式都有自己的Submit_button。 I have a text input in one of the forms and want to make it required to be not blank but it doesn't seem to work... 我在其中一种形式中输入了文本,并希望使其必须不为空白,但似乎不起作用...
userQueryForm = SQLFORM.factory(
Field('userQuery', label='', requires=IS_NOT_EMPTY() ),
submit_button = T('Generate Report')
)
The html that gets rendered is as follows 呈现的html如下
<td class="w2p_fw">
<input class="string" id="no_table_userQuery" name="userQuery" type="text" value="">
</td>
...
<tr id="submit_record__row">
<td class="w2p_fl"></td>
<td class="w2p_fw">
<input type="submit" value="Generate Report" class="btn">
</td>
</tr>
I want my <input>
to have an id so i can access it in Jquery... 我希望我的<input>
有一个ID,以便我可以在Jquery中访问它...
My ultimate goal is to not allow the form to be subitted if the text 我的最终目标是,如果文本不被引用,
You can access the submit button server-side DOM element via userQueryForm.custom.submit
, so to add an id
attribute: 您可以通过userQueryForm.custom.submit
访问提交按钮服务器端DOM元素,以便添加id
属性:
userQueryForm.custom.submit.update(_id='submit_button')
Alternatively, there are other methods to access the submit button via jQuery rather than relying on an id
. 另外,还有其他方法可以通过jQuery而不是依赖id
来访问Submit按钮。 For example: 例如:
jQuery('input[value="Generate Report"]')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.