Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/396.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
向隐藏输入添加Javascript值_Javascript_Jquery_Html_Variables - Fatal编程技术网

向隐藏输入添加Javascript值

向隐藏输入添加Javascript值,javascript,jquery,html,variables,Javascript,Jquery,Html,Variables,我正在尝试向隐藏的输入字段添加一个JavaScript变量。我该怎么做 HTML: JavaScript: 我需要的是: 我只想让变量PickedNumber在发送时隐藏输入类型。您只需执行以下操作: var inc=0; var pickednumbers=[2,3,4,8]; document.getElementByIdPickedNumber.setAttributevalue、JSON.StringifyPickedNumber; 打赌 调用myFunction的位置和方式?可能与1

我正在尝试向隐藏的输入字段添加一个JavaScript变量。我该怎么做

HTML:

JavaScript:

我需要的是:
我只想让变量PickedNumber在发送时隐藏输入类型。

您只需执行以下操作:

var inc=0; var pickednumbers=[2,3,4,8]; document.getElementByIdPickedNumber.setAttributevalue、JSON.StringifyPickedNumber; 打赌 调用myFunction的位置和方式?可能与1重复。我知道变量中填入了正确的数据。当我提醒它时,它有需要发送的数据,这些数据可能是重复的
<button type="button" class="submitFormOnClick btn btn-warning pull-right"
        style="margin-bottom:15px; margin-top:15px;" id="bet">Bet
</button>

<input type="hidden" name="controller" value="keno">
<input type="hidden" name="task" id="task" value="">
<input type="hidden" name="pickednumbers" id="pickednumbers">
<script type="text/javascript">
    var inc = 0;
    var pickednumbers = [];
    function myFunction(elmnt, color, id)
    {
        if(pickednumbers.length >= 20)
        {
            return false;
        }

        if (pickednumbers.indexOf(id) === -1)
        {
            pickednumbers.push(id);

            elmnt.style.background = color;
            inc = inc + 1;
            if(inc >= 20)
            {
                document.getElementById('onColor').setAttribute("style", "background-color:green");
            }
        }
        else
        {
            return false;
        }
    }
</script>