我試圖編寫這個網絡應用程序,讓用戶輸入有關他們的設備的重要信息,然後將其放置在JavaScript中的相關位置。這是我的代碼到目前爲止。使用ID獲取用戶輸入元素
<script type="text/javascript">
function update() {
var key = document.getElementById("key").value;
if (input.length < 40) {
alert("Please enter a valid input");
return;
}
document.getElementById("access key").innerHTML;
}
</script>
<script type="text/javascript">
function update() {
var device_id = document.getElementById("device_id").value;
if (input.length < 24) {
alert("please enter a valit input");
return;
}
document.getElementById("device_id").innerHTML;
}
</script>
<p><input type="text" id="key" autofocus placeholder = "Enter product key here" /></p>
<p><input type="text" id="device_id" autofocus placeholder = "Enter device ID here" /></p>
<p><input type="submit" value="Submit" onclick="update()"/></p>
<h1>Rotary Gate Systems</h1>
<article>
<a href="#" class="button open_button">Open</a>
</article>
<article>
<a href="#" class="button close_button">Close</a>
</article>
<article>
<p class="status_closed status_button">CLOSED</p>
<p class="status_open status_button">OPEN</p>
<p class="status_none status_button">NO CONNECTION</p>
</article>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.js'></script>
<script>/*jslint browser: true*/
/*global $, jQuery*/
/*jshint strict: true */
/*EDIT THESE VARIABLES*/
//key is the same as your 'access token'
var key = "key"
//device_id is the same as the 'core id'
var device_id = "device_id"
我想我可能會錯過提交按鈕中的某些東西,或者我想要做的事可能無法使用此屬性。有人可以看看這個,讓我知道我可能會搞砸嗎?
什麼你期望'的document.getElementById( 「快捷鍵」)的innerHTML做;'怎麼辦? – Thriggle
我的理論是改變代碼底部的「var key」和「var device_id」。 –