简体   繁体   English

从SHAREPOINT INFOPATH浏览器启用的表单上的输入字段中获取值

[英]Grab value from input field on SHAREPOINT INFOPATH browser enabled form

I'm trying to get the value of a textbox into a JavaScript variable. 我正在尝试将文本框的值转换为JavaScript变量。 ultimately I'm trying to hide or show different webparts depending on the value in the textbox. 最终,我试图根据文本框中的值隐藏或显示不同的Web部件。 I'm piecing the code together to test for input first. 我将代码拼接在一起以首先测试输入。 Below is the code for the textbox in question that I pulled from Firebug: 以下是我从Firebug中提取的文本框的代码:

<input onfocus="return (TextBox.OnFocus(this, event));" onblur="return (TextBox.OnBlur(this, event));" oninput="return  (TextBox.OnInput(this, event));" id="ctl00_m_g_ff1af521_db80_4f46_9a65_42671828173f_FormControl0_V1_I1_T82" scriptclass="TextBox" class="z_VYBB68eomwymAKXW_0 c5_VYBB68eomwymAKXW_0 ef_VYBB68eomwymAKXW_0" wrapped="true" direction="ltr" viewdatanode="83" formid="ctl00_m_g_ff1af521_db80_4f46_9a65_42671828173f_FormControl0" originalid="V1_I1_T82" tabindex="0" title="" value="Visible" style="position: relative;" type="text">

If I use the code below I get an "Undefined" error message(popup). 如果使用下面的代码,则会收到“未定义”错误消息(弹出窗口)。 As you can clearly see though, the value of the textbox = "Visible" as the code above tells us. 正如您可以清楚地看到的那样,上面的代码告诉我们,文本框的值=“可见”。

$(document).ready(function() 
{
    var HideWeb = $("#ctl00_m_g_ff1af521_db80_4f46_9a65_42671828173f_FormControl0_V1_I1_T82").val();
    alert(HideWeb);
});

I've also tried the following with no success (popup returns empty). 我也尝试了以下失败的尝试(弹出返回为空)。

var HideWeb = document.getElementById("#ctl00_m_g_ff1af521_db80_4f46_9a65_42671828173f_FormControl0_V1_I1_T82").value;
    alert(HideWeb);

I've also tried using the other ID numbers in hopes that one of them would work in the JavaScript\\Jquery code above. 我也尝试过使用其他ID号,希望其中一个可以在上面的JavaScript \\ Jquery代码中使用。 If someone could pick this apart and help me determine what the problem is I would appreciate it.Thank you. 如果有人可以分开解决这个问题并帮助我确定问题出在哪里,我将不胜感激。

This correspondes to a question I asked here....... https://sharepoint.stackexchange.com/questions/113969/showing-hiding-webparts-conditionally 这对应于我在这里问的一个问题....... https://sharepoint.stackexchange.com/questions/113969/showing-hiding-webparts-conditionally

尝试删除“#”

var HideWeb = $("ctl00_m_g_ff1af521_db80_4f46_9a65_42671828173f_FormControl0_V1_I1_T82").val();

you may try.. 你可以试试..

$("input:text[originalid='V1_I1_T82']").val()

This will return you the value.. 这将返回您的值。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM