简体   繁体   English

填充隐藏字段Microsoft JScript运行时错误:对象不支持此属性或方法

[英]Populating a hidden field Microsoft JScript runtime error: Object doesn't support this property or method

I am trying to populate a hidden field with the list box items. 我正在尝试使用列表框项目填充隐藏字段。 Currently I have a list box populating with the selected values. 目前,我有一个列表框,其中填充了选定的值。 I need to somehow populate a hidden field with the values so that I can use them on a different page. 我需要以某种方式填充值的隐藏字段,以便可以在其他页面上使用它们。 So the hidden field value would be like 123456,654987,546845 etc. separated by a comma getting the values from the list box. 因此,隐藏字段的值将类似于123456、654987、546845等,并用逗号分隔,以从列表框中获取值。 I am kinda stuck with the code below not sure how to achieve this and I am currently getting the error Microsoft JScript runtime error: Object doesn't support this property or method. 我有点卡在下面的代码中,不确定如何实现此目的,并且当前收到错误消息Microsoft JScript运行时错误:对象不支持此属性或方法。 Any ideas? 有任何想法吗?

<script language="javascript" type="text/javascript">
  function getSelected(source, eventArgs) {
      var s = $get("<%=DoctorNameTextBox.ClientID %>").value;

      var opt = document.createElement("option");
      opt.text = s.substring(s.length - 10);
      opt.value = s.substring(s.length - 10);

      document.getElementById('<%= NPIListbox.ClientID %>').options.add(opt);

      var Source = document.getElementById('<%= NPIListbox.ClientID %>');
      var Target = document.getElementById('<%= hidListBox.ClientID %>');


              var HiddenList = document.getElementById('<%= hidListBox.ClientID %>') //The hidden field
              var SelectedValue = Source.options[Source.options.selectedIndex].value + ','; // Hidden List is comma seperated
              var newOption = new Option(); // Create a new instance of ListItem
              newOption.text = Source.options[Source.options.selectedIndex].text;
              newOption.value = Source.options[Source.options.selectedIndex].value;

              Target.options[Target.length] = newOption; //Append the item in Target
              Source.remove(Source.options.selectedIndex);  //Remove the item from Source
              if (HiddenList.value.indexOf(SelectedValue) == -1) {
                  HiddenList.value += SelectedValue; // Add it to hidden list
              }
              else {
                  HiddenList.value = HiddenList.value.replace(SelectedValue, ""); // Remove from Hidden List
              }


  }

I believe .value is the issue here. 我相信.value是这里的问题。 Since you are using jQuery, use this: .val() 由于您使用的是jQuery,请使用以下代码:.val()

http://api.jquery.com/val/ http://api.jquery.com/val/

I solved it thank you 我解决了,谢谢

hid.value = hid.value + opt.text + ',';
Dim data As String = HiddenOptions.Value.TrimEnd(","c)

暂无
暂无

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

相关问题 Microsoft JScript运行时错误:对象不支持此属性或方法 - Microsoft JScript runtime error: Object doesn't support this property or method Microsoft JScript运行时错误对象不支持此属性或方法 - Microsoft JScript runtime error Object doesn't support this property or method FullCalendar错误-Microsoft JScript运行时错误:对象不支持此属性或方法 - FullCalendar error - Microsoft JScript runtime error: Object doesn't support this property or method 出现js错误:Microsoft JScript运行时错误:对象不支持此属性或方法 - getting the js error : Microsoft JScript runtime error: Object doesn't support this property or method 我们如何清除此错误Microsoft JScript运行时错误:对象不支持属性或方法&#39;querySelectorAll - how can we clear this error Microsoft JScript runtime error: Object doesn't support property or method 'querySelectorAll Microsoft JScript运行时错误:对象不支持属性或方法&#39;__defineGetter__ - Microsoft JScript runtime error: Object doesn't support property or method '__defineGetter__ Microsoft JScript 运行时错误:对象不支持属性或方法“datepicker” - Microsoft JScript runtime error: Object doesn't support property or method 'datepicker' Microsoft JScript运行时错误:对象不支持属性或方法“ radopen” - Microsoft JScript runtime error: Object doesn't support property or method 'radopen' Microsoft JScript运行时错误:对象不支持IE9中的属性或方法&#39;getElementsByTagName&#39; - Microsoft JScript runtime error: Object doesn't support property or method 'getElementsByTagName' in IE9 Microsoft JScript运行时错误:对象不支持属性或方法“ html” - Microsoft JScript runtime error: Object doesn't support property or method 'html'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM