最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Using button instead href to call action in symfony2 - Stack Overflow

programmeradmin2浏览0评论

I use href to send action to the controllr but I ask if it's possible to use button instead href to do the action. this is my code

<a href="{{ path('adduser') }}" class="btn btn-lg btn-default highlight_black stylish ">create user</a>

so instead <a href ...> I want to use

<input type="button">

Thanks for help

I use href to send action to the controllr but I ask if it's possible to use button instead href to do the action. this is my code

<a href="{{ path('adduser') }}" class="btn btn-lg btn-default highlight_black stylish ">create user</a>

so instead <a href ...> I want to use

<input type="button">

Thanks for help

Share Improve this question edited Feb 16, 2016 at 19:59 chalasr 13.2k5 gold badges43 silver badges83 bronze badges asked Feb 16, 2016 at 9:31 Majdi TalebMajdi Taleb 7613 gold badges9 silver badges26 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

I added a script

document.getElementById("mybutton").onclick = function () {
    location.href = "{{ path('adduser') }}";
};

and now it work perfectly

Thanks for your helps

I don't see the point of make your links using an input, but yes, you can.

Do something like this :

<input type="button" onclick="location.href = {{ path('adduser') }};" />
发布评论

评论列表(0)

  1. 暂无评论