将字段中的值添加到 JavaScript 函数
我有一个 JavaScript 函数 checkStatus()
,它接受四个参数 bus_company_name,bus_id,bus_time
和 bus_date
。前三个参数来自数据库,但第四个参数将由用户输入。为此,我编写了如下 HTML:
{foreach name = feach item = k from = $allBuses}
<p>
{$k->bus_company_name}<br />
A/C {$k->bus_is_ac}<br />
Date : <input type="text" name="date" id="dt" />yyyy/mm/dd
<a href="javascript:checkStatus('{$k->bus_company_name}','{$k->bus_id}','{$k->bus_time}',jrny_date)">Status</a>
</p>
{/foreach}
我想要来自 id date
的输入类型的 jrny_date
。我怎样才能实现它?
I have a javascript function checkStatus()
which accepts four argumentsbus_company_name,bus_id,bus_time
and bus_date
. The first three arguments are coming from database, but the fourth one will be entered by user . For that I have written the HTML like :
{foreach name = feach item = k from = $allBuses}
<p>
{$k->bus_company_name}<br />
A/C {$k->bus_is_ac}<br />
Date : <input type="text" name="date" id="dt" />yyyy/mm/dd
<a href="javascript:checkStatus('{$k->bus_company_name}','{$k->bus_id}','{$k->bus_time}',jrny_date)">Status</a>
</p>
{/foreach}
I want jrny_date
from input type with id date
. How can I implement that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果使用它,您将把元素值作为参数传递。
但您也可以进入函数 checkStatus。
If you use this, you will pass the element value as param.
But you also can get inside the function checkStatus.
由于您要循环访问项目列表,因此我建议在每次迭代时使用当前索引来创建唯一的日期 ID。然后,您可以将其传递给脚本并通过 ID 获取元素的值:
Since you're looping through a list of items, I would recommend using the current index at each iteration to create a unique date ID. You can then pass this to your script and get the element's value by ID there: