Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.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中的html代码传递javascript变量_Javascript_Html_Variables_Parameters_Onclick - Fatal编程技术网

通过javascript中的html代码传递javascript变量

通过javascript中的html代码传递javascript变量,javascript,html,variables,parameters,onclick,Javascript,Html,Variables,Parameters,Onclick,我有一个JavaScript,在其中动态创建一个带有确认按钮的HTML表单。单击确认按钮时,某些JavaScript变量需要传递给同一文件中的另一个JS方法。但是我在我编写的代码中遇到了一个错误,它不遵循同一个js文件,而是另一个jsp文件,尽管它没有直接链接或以任何方式受到它的影响 JS功能,点击按钮 if (dropElem == "stream ui-draggable ui-draggable-handle") { var newAgent = $('<div>');

我有一个JavaScript,在其中动态创建一个带有确认按钮的HTML表单。单击确认按钮时,某些JavaScript变量需要传递给同一文件中的另一个JS方法。但是我在我编写的代码中遇到了一个错误,它不遵循同一个js文件,而是另一个jsp文件,尽管它没有直接链接或以任何方式受到它的影响

JS功能,点击按钮

if (dropElem == "stream ui-draggable ui-draggable-handle") {
    var newAgent = $('<div>');
    jsPlumb.addEndpoint(newAgent,connectorProperties);
    newAgent.attr('id', i).addClass('streamdrop');
    var elemType = "table";
    $("#container").addClass("disabledbutton");
    $("#toolbox").addClass("disabledbutton");

    $('#container').append(newAgent);

    $("#lot").append(

            "<h4>TABLE</h4></br>"+
            "<h5> Select a Table </h5></br>"+
            "<div class='col-md-12'>"+
                "<select id='attr-combobox-style' name='attr-combobox-style' class='form-control' id='tableListDropDownCombo'>"+
                    "<option value='Select an option'>Select an option</option>"
    );

    for(var q=0;q<StreamArray.length;q++)
    {
        $("#attr-combobox-style").append(
                  "<option value="+StreamArray[q][0]+">"+StreamArray[q][0]+"</option>"+                             
                "</select>"+
              "</div>"
         );
    }

    $("#lot").append(
            "<div class='form-group'></br>"+
                "<label class='col-md-12 control-label' for='tableFormConfirmButton'></label></br>"+
                "<label class='col-md-12 control-label' for='tableFormConfirmButton'></label></br>"+
                "<label class='col-md-12 control-label' for='tableFormConfirmButton'></label></br>"+
                "<label class='col-md-2 control-label' for='tableFormConfirmButton'></label>"+
                "&nbsp<button id='tableFormConfirmButton' name='tableFormConfirmButton' class='btn btn-primary' onclick='storeTableFormInfo("+newAgent+","+i+","+e+","+mouseTop+","+mouseLeft+","+elemType+")'>Confirm</button>"+
                "&nbsp&nbsp<button id='tableFormCancelButton' name='tableFormCancelButton' class='btn btn-danger'>Cancel</button>"+
            "</div></br>"
    );

    $("property").show();
    $(".toolbox-titlex").show();
    $(".panel").show();

    i++;    //Increment the Element ID for the next dropped Element
    finalElementCount=i;
}
if(dropElem==“流ui可拖动ui可拖动句柄”){
var newAgent=$('');
jsPlumb.addEndpoint(新代理、连接财产);
newAgent.attr('id',i).addClass('streamdrop');
var elemType=“表格”;
$(“#容器”).addClass(“禁用按钮”);
$(“#工具箱”).addClass(“禁用按钮”);
$('#container').append(newAgent);
$(“#地段”)。追加(
“表
”+ “选择一个表
”+ ""+ ""+ “选择一个选项” );
对于(var q=0;q您需要声明javascript全局变量,并需要在脚本标记中首先定义,如下所示

<script type='text/javascript' > 
var myGlobalVariable = false; 
</script>
<script type='text/javascript' src='js/Other.js'></script>     
... 
<script type='text/javascript' > 
 // other java script code that depend on Other.js 
</script>

var myGlobalVariable=false;
... 
//依赖于other.js的其他java脚本代码

一开始,我已经在同一个javascript文件中声明了一个全局变量,但仍然遇到相同的错误。请您使用dubug代码并检查您的文件中是否有带值的变量?我检查过了,正如您所提到的,它是可用的