简体   繁体   English

将数组作为参数传递给Javascript

[英]Pass Array as a parameter in Javascript

This function is used to check if the checkbox is selected or not.Can somebody help how to pass the array as a parameter to URL which will call a stored procedure. 该函数用于检查是否选中了该复选框。有人可以帮助如何将数组作为参数传递给URL,该URL将调用存储过程。

function js_remove_masters(theForm) {
  var vCheckedCount = 0;
  var vContinue = true;
  var mycheckedarr = [];
  var myuncheckedarr = [];
  //check to see if anything is selected
  if ((theForm.selected.length == null) && (!(theForm.selected.checked))) {
    vContinue = false;
    alert("Please select an item to be deleted.");
  } else if (theForm.selected.length != null) {
    for (var i = 0; i < theForm.selected.length; i++) {
      if (theForm.selected[i].checked) {
        vCheckedCount = 1;
        mycheckedarr.push = theForm.selected[i].value;
      } else {
        myuncheckedarr.push = theForm.selected[i].value;
      }
    }

    if (vCheckedCount == 0) {
      vContinue = false;
      alert("Please select an item to be deleted.");
    }
  }
  if (vContinue) {
    theForm.action = ("library_search_pkg_nv1.remove_checkin_masters");
    -- - here how to pass array parameters
    theForm.submit();
  }
}
procedure remove_masters(
  masterID in smallarray
  default smallempty,
  masterIDunselected in smallarray
  default smallempty
);

Just get rid of the JavaScript entirely. 完全摆脱JavaScript。 You are submitting the form. 您正在提交表格。

If a checkbox is checked then its name/value pair will be included in the form data. 如果选中复选框,则其名称/值对将包含在表单数据中。

If it isn't checked, then it won't be. 如果未选中,则不会。

If you have a bunch of checkboxes (or other elements) with the same name, then most server side form data parsing libraries will express that as an array automatically. 如果您有一堆具有相同名称的复选框(或其他元素),则大多数服务器端表单数据解析库会将其自动表示为数组。 The main exception is PHP which requires that you put [] on the end of the name first. 主要的例外是PHP,它要求您首先将[]放在名称的末尾。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用javascript传递数组参数 - How to pass an array parameter with javascript 如何在JavaScript代码函数中将数组作为参数传递? - How to pass array as parameter in javascript code function? 将数组从 JSP 作为参数传递给 JavaScript function - Pass array from JSP as parameter to JavaScript function 加载javascript时无法传递参数(在数组中) - Cannot pass parameter (in array) when loading javascript 如何将PHP数组参数传给Javascript Function? - How to pass PHP array parameter to Javascript Function? Javascript将数组作为参数传递给具有多个参数的函数 - Javascript Pass Array as a Parameter to a Function with Multiple Parameters 将数组作为参数从JavaScript中的ajax调用传递给控制器 - Pass an array as parameter to a controller from an ajax call in JavaScript Javascript 函数数组:将每个函数作为参数传递给另一个函数 - Javascript array of functions: Pass each function as parameter to another function 如何正确地将整个数组(而不是其项目)作为参数传递? (JavaScript) - How to correctly pass a whole array (not its items) as a parameter? (Javascript) 如何将关联数组参数从javascript传递给ActiveX对象? - How to pass associative Array parameter from javascript to ActiveX object?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM