I write this html code with mojolicius code mixed. The idea is to submit the form when I select a radio input that is stylized as a Bootstrap button.

我用mojolicius代码混合编写这个html代码。我的想法是在选择一个风格化为Bootstrap按钮的无线电输入时提交表单。

If I put a submit type input, I select the Bootstrap button and I submit it, it works perfectly. But when I use this function (submitForm(node)) to submit the form, it seems to submit it, but is doesn't do anything. The Firefox debugger doesn't throw any error.

如果我输入提交类型,我选择Bootstrap按钮并提交它,它完美地运行。但是当我使用这个函数(submitForm(node))来提交表单时,似乎提交它,但是没有做任何事情。 Firefox调试器不会抛出任何错误。

<form method="post" id="runform">
%if (keys %$base) {
%for my $option (sort keys %$base) {

  <div class="col-sm-4">
  <div class="panel panel-success machine">

...                           

    <div class="btn-group pannel-body" data-toggle="buttons">
       <label class="btn btn-success" id="base_action" onclick="submitForm(<%= $option %>)">
          <input name="id_base" id="submit<%= $option %>" type="radio" value="<%= $option %>"><strong>&nbsp;<i class="fa fa-play" aria-hidden="true"></i>&nbsp;Start this Machine</strong>
       </label>                              
    </div>

 </div>
 </div>
%}
</form>

The JavaScript Function:

JavaScript函数:

function submitForm(node) {
    var id = "submit"+ node ;
    document.getElementById(id).checked=true;
    document.getElementById("runform").submit();
}

Thanks

1 个解决方案

#1


0

You lack an action attribute on the form, so it gets submitted to the current page, that's why it seems to submit, but does nothing, because it's likely you have configured your server to just reply with the same page to the request.

您在表单上缺少一个操作属性,因此它会被提交到当前页面,这就是为什么它似乎提交,但什么也没做,因为您可能已经将服务器配置为仅使用相同的页面回复请求。

Point the form to the right URL.

将表单指向正确的URL。

更多相关文章

  1. Objective-C方法/函数调用。 (来自javascript示例)
  2. 在提交表单之前确定重复值
  3. Javascript函数的4种调用方法详解
  4. JavaScript(ES5)使用保留字作函数名
  5. 从列表单击功能获取列表项的值
  6. 将JavaScript函数的值插入SQL Server数据库
  7. 轮播图---可以动态添加图片,(封装成一个函数)
  8. javascript高阶函数map和reduce
  9. jQuery插件:如何将元素引用传递给回调函数?

随机推荐

  1. android 横竖屏锁定
  2. Relative Layout 中用到的一些属性
  3. View有关基础
  4. Android(安卓)UI控件之ListView实现圆角
  5. 指纹支付相关的细节处理
  6. android api 中文 (73)—— AdapterView
  7. Android开发指南-用户界面-事件处理
  8. Android上超级好用的前端调试方法(adb rev
  9. DeskSMS 在電腦收發、回覆 Android(安卓)
  10. Android(安卓)入门第十讲02-广播(广播概述