このスクリプトで JavaScript から 8 つを超える値を受け取るのに問題があります...ドロップダウン オプション (選択) のフィールドに自動入力する必要があります。正常に動作しますが、8 つを超える値を取得できません...問題?ありがとう!
<script type="text/javascript">
// Format of StoreDetails()
// Name,Addr1,Addr2,Addr3,Phone,FAX,Email,Webpage, Url
var StoreDetails = [
['Please select','','','','','','','',''],
['Please select','test1','test2','test3','test4','test5','test6','test7','test8']
// Note: no comma
];
function Setup(TA) {
var str = "<select id='Store' class='styled-select' onchange='StoreInfo()'>";
for (var i=0; i<StoreDetails.length; i++) {
str += '<option value="'+StoreDetails[i].join('|')+'">'+StoreDetails[i] [0]+'</option>';
}
str +='</select>';
document.write(str);
}
function StoreInfo() {
var sel = document.getElementById('Store').selectedIndex;
var tmp = []; tmp.push(sel);
for (var i=1; i<8; i++) {
tmp.push(StoreDetails[sel][i]);
}
document.getElementById('txtName').value = tmp[1];
document.getElementById('txtAddr1').value = tmp[2];
document.getElementById('txtAddr2').value = tmp[3];
document.getElementById('txtAddr3').value = tmp[4];
document.getElementById('txtPhone').value = tmp[5];
document.getElementById('txtPhone2').value = tmp[6];
document.getElementById('txtEmail').value = tmp[7];
document.getElementById('txtWebpage').value = tmp[8];
document.getElementById('txtUrl').value = tmp[9];
}
</script>
</head>
<body>
<div class="container">
<header class="clearfix">
<img src="logo.png"/>
<nav class="codrops-demos">
<a class="current-demo" href="index.php">Some text</a>
</nav>
</header>
<section class="main clearfix">
<div class="fleft">
<p>Da bi porucili vizit karte, izaberite ime i kolicinu, zatim potvrdite.</p>
</div>
<div class="fleft">
<form id="testconfirmJQ" name="testconfirmJQ" method="post" action="output.php">
<script type="text/javascript">Setup();</script>
<table border="0">
<input type="text" hidden="hidden" id="txtName" name="txtName" size="30" value=""> </td></tr>
<input type="text" hidden="hidden" id="txtAddr1" name="txtAddr1" size="30" value=""> </td></tr>
<input type="text" hidden="hidden" id="txtAddr2" name="txtAddr2" size="30" value=""></td></tr>
<input type="text" hidden="hidden" id="txtAddr3" name="txtAddr3" size="30" value=""> </td></tr>
<input type="text" hidden="hidden" id="txtPhone" name="txtAddr3" size="30" value=""> </td></tr>
<input type="text" hidden="hidden" id="txtPhone2" name="txtPhone2" size="30" value=""></td></tr>
<input type="text" hidden="hidden" id="txtEmail" name="txtEmail" size="30" value=""> </td></tr>
<input type="text" hidden="hidden" id="txtUrl" name="txtUrl" size="30" value=""></td> </tr>
<tr><td>How much?:</td><td><input type="text" id="kolicina" name="kolicina" size="5" value=""></td></tr>
<tr><td><input id="submitJQ" name="submitJQ" type="submit" class="styled-button-1" value="Confirm" /></td></tr>
</table>
</form>