JavaScript创建了输入,现在我需要得到这些输入的值

JavaScript创建了输入,现在我需要得到这些输入的值,javascript,Javascript,我有一些脚本,我用Javascript创建了一个表, 在其中一列中,它有一个输入。现在,一经提交,我将 希望获取输入中输入的数据,以便保存。 这是我的密码。很难看,对不起 下面是我如何创建表的。 schedArray是在另一个函数中创建的 function schedTable() { var tableCode = '<table id="longCallData" width="99.5%"> <tr> <th>' + schedArray[1][

我有一些脚本,我用Javascript创建了一个表, 在其中一列中,它有一个输入。现在,一经提交,我将 希望获取输入中输入的数据,以便保存。 这是我的密码。很难看,对不起

下面是我如何创建表的。 schedArray是在另一个函数中创建的

function schedTable() {
    var tableCode = '<table id="longCallData" width="99.5%"> <tr> <th>' + schedArray[1][0] + '</th> <th>' + schedArray[1][1] + '</th> <th>' + schedArray[1][2] + '</th><th>' + schedArray[1][3] + '</th> <th>' + schedArray[1][4] + '</th> <th>' + schedArray[1][5] + '</th><th>' + schedArray[1][6] + '</th> <th>' + schedArray[1][7] + '</th> <th>' + schedArray[1][8] + '</th><th>' + schedArray[1][9] + '</th> <th>' + schedArray[1][10] + '</th></tr>';
    var oddeven = new Boolean();

    for (i = 2; i < schedArray.length; i++) {
        oddeven = !oddeven;
        tableCode += 'enter code here<tr class="row' + oddeven + '">';
        tableCode += '<th>' + schedArray[i][0] + '</th> <th>**<input type="text" name="sched">**</th> <th>' + schedArray[i][2] + '</th><th>' + schedArray[i][3] + '</th> <th>' + schedArray[i][4] + '</th> <th>' + schedArray[i][5] + '</th><th>' + schedArray[i][6] + '</th> <th>' + schedArray[i][7] + '</th> <th>' + schedArray[i][8] + '</th><th>' + schedArray[i][9] + '</th> <th>' + schedArray[i][10] + '</th></tr>';
    }

    tableCode += '</table>';
    var tabSpan = document.getElementById('shiftTable');    //Get display location
    tabSpan.innerHTML = tableCode;  //Place data in display element

    var count = schedArray.length - 2;
    var counted = schedArray.length - 2;
    var ctnSpan = document.getElementById('countOne');  //Get display location
    ctnSpan.innerHTML = count;  //Place data in display element
    var cntSpan = document.getElementById('countTwo');  //Get display location
    cntSpan.innerHTML = counted;    //Place data in display element
}
如果我使用document.getElementBy*('sched')。值加上或不加上out值, *已使用其他代码更改名称、类、标记和名称,但未成功

下面是可能更有用的完整代码:

<!DOCTYPE html>
<html>

<head>


    <HTA:APPLICATION ID="Shift_Bid" 
    APPLICATIONNAME="ShiftBid" 
    BORDER="thin"
    CAPTION="yes"
    SHOWINTASKBAR="yes"
    SINGLEINSTANCE="Yes"
    SYSMENU="yes"
    selection="no"
    minimize="yes"
    >

<title>Shift Bid</title>

    <style type="text/css">
    body {overflow:hidden;}

    #titleBid {position:absolute; top:10px; left:160px;}
    #nameSpace {position:absolute; top:50px; left:200px;}
    #oracleSpace {position:absolute; top:50px; left:400px;}
    #agentName {border:1px solid black;}
    #agentOracle {border:1px solid black;}
    #info {position:absolute; top:70px; left:120px; font-size:20px; font-weight:bolder;}
    #contentSpace {position:absolute; top:100px; left:5px; width:1250px; height:480px; border:1px solid black; overflow:hidden;}
    #countBid {position:absolute; top:580px; left:120px; font-size:20px; font-weight:bolder;}
    #notAtion {position:absolute; top:610px; left:5px; width:1250px; height:120px; border:1px solid black; overflow:hidden;}
    #comment {position:absolute; top:5px; left:10px; font-size:15pt;}
    #notes {position:absolute; top:30px; left:5px; width:1000px; height:80px; border:1px solid black; overflow:hidden;}
    #action {position:absolute; top:2px; left:1016px; width:228px; height:114px; padding-left:2px; border:1px solid black; font-size:12pt; font-weight:bolder;}
    #submit {position:absolute; top:79px; left:23px; width:180px; height:30px; background-color:green; font-size:15pt; font-weight:bolder;}
    table input {width:15px;}
    table {border-collapse:collapse; font-size:10pt; margin-left:2px;}
    table th {border-top:1px solid black; font-weight:bolder;}
    .rowfalse{background-color: #E6E6E6;}
    .rowtrue{background-color: #FFFFFF;}
    table th:hover {font-size:12pt;}

    </style>


<script>


window.resizeTo(1310,800);
var Fo = new ActiveXObject("Scripting.FileSystemObject");
var network = new ActiveXObject('WScript.Network');
var objSysInfo = new ActiveXObject("ADSystemInfo")
var objUser = GetObject("LDAP://" + objSysInfo.UserName)
var user = {'Name': objUser.displayName, 'ID': objUser.sAMAccountName}
var dir = "//directory/of/file";


getForm();



function getAgent(){
    var name = user.Name;
    var oracle = user.ID;

var nameSpan = document.getElementById('agentName'); 
nameSpan.innerHTML = '  ' + name + '  '; 

var oracleSpan = document.getElementById('agentOracle'); 
oracleSpan.innerHTML = '  ' + oracle + '  ';

    nameSpan.style.color = "#006600"; 
    oracleSpan.style.color = "#006600"; 
}





function getForm() {
var dataPath = dir + '/Agent_Form.csv'; 
if(Fo.FileExists(dataPath)){ 
    var dataFile = Fo.OpenTextFile(dataPath,1); 
    schedArray = new Array(); 
    while(!dataFile.AtEndOfStream){ 
        var line = dataFile.Line - 1; 
        schedArray[line] = dataFile.readLine(); 
    }
    dataFile.close();
    for(i=0;i<schedArray.length;i++){
        schedArray[i] = schedArray[i].split(",");
    }
}
}



function getStuff(){
getAgent();
getTitle();
schedTable();
}



function startUp(){
getForm();
getStuff();
}   


function getTitle(){
var title = schedArray[0][1];

var titleData = title;


var titleSpan = document.getElementById('titleBid'); 
titleSpan.innerHTML = '<h1>' + titleData + '</h1>';

}   

function schedTable(){
var tableCode = '<table id="longCallData" width="99.5%"> <tr> <th>' + schedArray[1][0] + '</th> <th>' + schedArray[1][1] + '</th> <th>' + schedArray[1][2] + '</th><th>' + schedArray[1][3] + '</th> <th>' + schedArray[1][4] + '</th> <th>' + schedArray[1][5] + '</th><th>' + schedArray[1][6] + '</th> <th>' + schedArray[1][7] + '</th> <th>' + schedArray[1][8] + '</th><th>' + schedArray[1][9] + '</th> <th>' + schedArray[1][10] + '</th></tr>';
var oddeven = new Boolean();
for(i=2;i<schedArray.length;i++){
oddeven = !oddeven;
tableCode += '<tr class="row'+ oddeven +'">';
tableCode += '<th>' + schedArray[i][0] + '</th> <th><input type="text" name="sched"></th> <th>' + schedArray[i][2] + '</th><th>' + schedArray[i][3] + '</th> <th>' + schedArray[i][4] + '</th> <th>' + schedArray[i][5] + '</th><th>' + schedArray[i][6] + '</th> <th>' + schedArray[i][7] + '</th> <th>' + schedArray[i][8] + '</th><th>' + schedArray[i][9] + '</th> <th>' + schedArray[i][10] + '</th></tr>';

}

tableCode += '</table>';
var tabSpan = document.getElementById('shiftTable'); 
tabSpan.innerHTML = tableCode; 

var count = schedArray.length - 2;
var counted = schedArray.length - 2;
var ctnSpan = document.getElementById('countOne');
ctnSpan.innerHTML = count; 
var cntSpan = document.getElementById('countTwo'); 
cntSpan.innerHTML = counted; 

}





 function submit(){
var message = confirm("This Will Submit Your Bid And Close Out The Form, Are You Sure You Are Ready To Submit?", "");
if( message!=null && message!=""){
        var extras = document.getElementById('notes').value;

        var tabSpan = document.getElementById('shiftTable');
        tabSpan.getElementsByName("sched")[0].value;
var s = Fo.OpenTextFile('file.csv', 8, true, 0);

s.WriteLine(user.Name+','+user.ID+',,'+tabSpan+','+extras);
s.Close();
alert("Thank You!");
}
}   


</script>

</head>

<body onload="startUp()">

<div id="main" >

<div id="agentSpace">

<span id="titleBid"></span>
<div id="nameSpace">
Name :
<span id="agentName"> </span>
</div>
<div id="oracleSpace">
Oracle :
<span id="agentOracle"> </span>
</div>
<div id="info">Please make sure to enter your name and oracle in the fields below.</div>
</div>
<div id="contentSpace">
<span id="shiftTable"></span>
</div>
<div id="countBid">Please list choices from 1-<span id="countOne"></span>, all fields need to be numbered. Top choice is 1, bottom choice is <span id="countTwo"></span>.</div>
<div id="notAtion"><div id="comment">Comments: (ie. Public transportation needs to include what the earliest start and end times)</div><input id="notes" value=""><div id="action">Please Review Your Selections and Make Note if you have Concerns. Then Submit Your Bid. Thank You!<button id="submit"onclick="submit()">Submit</button></div></div>
</div>

</body>

</html>

轮班投标
正文{溢出:隐藏;}
#标题ID{位置:绝对;顶部:10px;左侧:160px;}
#命名空间{位置:绝对;顶部:50px;左侧:200px;}
#oracleSpace{位置:绝对;顶部:50px;左侧:400px;}
#代理名称{边框:1px纯黑;}
#agentOracle{边框:1px纯黑;}
#信息{位置:绝对;顶部:70px;左侧:120px;字体大小:20px;字体重量:粗体;}
#contentSpace{位置:绝对;顶部:100px;左侧:5px;宽度:1250px;高度:480px;边框:1px纯黑色;溢出:隐藏;}
#countBid{位置:绝对;顶部:580px;左侧:120px;字体大小:20px;字体重量:粗体;}
#符号{位置:绝对;顶部:610px;左侧:5px;宽度:1250px;高度:120px;边框:1px纯黑色;溢出:隐藏;}
#注释{位置:绝对;顶部:5px;左侧:10px;字体大小:15pt;}
#注{位置:绝对;顶部:30px;左侧:5px;宽度:1000px;高度:80px;边框:1px纯黑;溢出:隐藏;}
#动作{位置:绝对;顶部:2px;左侧:1016px;宽度:228px;高度:114px;左侧填充:2px;边框:1px纯黑色;字体大小:12pt;字体重量:粗体;}
#提交{位置:绝对;顶部:79px;左侧:23px;宽度:180px;高度:30px;背景色:绿色;字体大小:15pt;字体重量:粗体;}
表输入{宽度:15px;}
表{边框折叠:折叠;字体大小:10pt;左边距:2px;}
表th{边框顶部:1px纯黑色;字体粗体;}
.rowfalse{背景色:#e6;}
.rowtrue{背景色:#FFFFFF;}
表th:hover{font size:12pt;}
窗口。resizeTo(1310800);
var Fo=新的ActiveXObject(“Scripting.FileSystemObject”);
var network=newActiveXObject('WScript.network');
var objSysInfo=新的ActiveXObject(“ADSystemInfo”)
var objUser=GetObject(“LDAP://”+objSysInfo.UserName)
var user={'Name':objUser.displayName,'ID':objUser.sAMAccountName}
var dir=“//目录/of/file”;
getForm();
函数getAgent(){
var name=user.name;
var oracle=user.ID;
var nameSpan=document.getElementById('agentName');
nameSpan.innerHTML=''+name+'';
var oracleSpan=document.getElementById('agentOracle');
oracleSpan.innerHTML=''+oracle+'';
nameSpan.style.color=“#006600”;
oracleSpan.style.color=“#006600”;
}
函数getForm(){
var dataPath=dir+'/Agent_Form.csv';
如果(Fo.FileExists(dataPath)){
var dataFile=Fo.OpenTextFile(dataPath,1);
schedArray=新数组();
而(!dataFile.AtEndOfStream){
var line=dataFile.line-1;
schedArray[line]=dataFile.readLine();
}
dataFile.close();

对于(i=0;i可能是因为您调用了getElementByName而不是getElementsByName

getElementsByName返回一个数组,因此您应该这样尝试:

document.getElementsByName("sched")[0].value
但您必须确保只有一个名为sched的对象,或者知道其索引

也许您还应该尝试使用DOM: var tabSpan=document.getElementById('shiftTable')

//创建表
table=document.createElement(“表”);
//创建表格标题行
tableHeaderLine=document.createElement(“tr”);

对于(j=0;i)当您选择by
name
时,您会得到一个集合作为回报。因此,如果只有一个
input
具有该名称,您需要访问集合的索引
[0]
。我不知道您的
onsubmit()在哪里
已定位,但如果每行有一个,您可以稍微更改它,然后遍历到该行的
输入。
。如果您对代码应用清晰的缩进,并使一些句子更清晰,您的问题将更容易理解。我已用整个代码更新了条目。…onsubmit()是在html中的一个按钮上。我已经尝试过这个和其他的代码,它给我一个错误“对象不支持属性或方法'getElementByName'”我看到它多次出现错误,但没有其他错误,对于任何GetElements,你确定你尝试过getElementsByName吗?你必须在元素上加一个S,以复数形式。我已经添加了我的全部代码…也许会有帮助…我添加了你的建议,尽管我已经从完整代码中删除了它。我甚至尝试过做另一个有趣的事情在执行获取和数组生成的submit函数中调用的Action…仍然没有var choice=“”;var taskArray=new array();$(“input[name=sched]”)。each(function(){taskArray.push($(this.val());});for(i=0;ivar elem=document.getElementsByTagName('input');var arr=new array();var i=0;var iarr=0;var att;for(;idocument.getElementsByName("sched")[0].value
// Create table
table = document.createElement("table");

// Create table header lines
tableHeaderLine = document.createElement("tr");
for (j = 0; i <= 10; j++)
{
    cell = document.createElement("th");
    cell.innerHTML = schedArray[1][j];
    tableHeaderLine.appendChild(cell);
}

// Create table lines
for (i = 2; i < schedArray.length; i++)
{
    line = document.createElement("tr");
    table.appendChild(line);

    for (j = 0; i <= 10; j++)
    {
        cell = document.createElement("th");

        if (j == 1)
        {
            schedInput = document.createElement("input");
            schedInput.setAttribute("type", "text");
            schedInput.name = "sched";
            cell.appendChild(schedInput);
        }
        else
        {
            cell.innerHTML = schedArray[i][j];
        }
    }  
}

// Append table to tabSpan
tabSpan.appendChild(table);