javascript - 拉拉维尔 : How to get anchor tag value in variable and use this variable in the input field?

标签 javascript php jquery laravel laravel-5.5

这个$emp->id给了我一个准确的id,所以这不是问题,我只是得到id={{$emp->id }} 从此?请帮助。

<a href="{{'/employee'}}?id={{$emp->id}}" type="button" name="u_id" > Apply Attribute </a>

单击“应用”按钮后,使用该值,它总是返回第一个用户 ID,或者如果我在 foreach 循环之外使用它,它将给我第二个用户 ID,所以如果我们在单击 href 时得到并想要将此 id 值存储在变量中并在值中使用它?那么请帮我从 anchor 标记中获取值?如果你解决这个问题我很高兴。提前感谢开发人员。

<form action="{{'/rating'}}" method="post">
 {{csrf_field()}} 

 <input type="hidden" name="user_id" value="{{$emp->id}}" />

 <input type="submit"  style="margin-bottom: 10px;" class="btn btn-success pull-right" name="apply" value="Apply"/>

</form>

最佳答案

你为什么要拉动{{'/employee'}}?

@foreach($employ as $emp)
   <tr> 
      <td>{{$emp->name}}</td>
   <td> 
      <a href="/employee?id={{$emp->id}}" type="button" name="u_id"class="btn btn-primary" data-toggle="modal" data-target="#myModal"> 
         Apply Attribute 
      </a>
   </td>
@endforeach

关于javascript - 拉拉维尔 : How to get anchor tag value in variable and use this variable in the input field?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47517010/

相关文章:

javascript - 有没有办法交叉淡化相对定位的 div(具有动态高度)?

javascript - jQuery if/else 语句不起作用

javascript - Meteor.call 不等待结果

javascript - 使用 Composer 更好地管理我的依赖项

javascript - 无法在 Express js 中处理 POST 请求

php - 数据库未捕获PHP文件中的任何内容

php - PHP 中文件父目录的完整绝对路径

php - 为什么 `array_diff_ukey`调用了那么多次比较函数?

JQuery 文档就绪功能在 IE 中不起作用

javascript - 使用 D3 无法显示 SVG 异物