![](/img/trans.png)
[英]how to pull data with one common field and make nested array in javascript
[英]How to pull javascript data into a form input field
我正在嘗試創建健身房會員數據庫,它需要存儲用客戶的網絡攝像頭拍攝的照片。 我已經使用了凸輪,一旦您拍照,就可以使用以下代碼“回顯”文件的網址。
下面的代碼加載一個URL:
<script type="text/javascript">
function getSnap(linky){
alert(linky);
}
</script>
我的問題是如何獲取它,以便上面的代碼自動填充到文本字段中?
任何幫助,將不勝感激 :)
假設您有一個名為#example
的輸入,然后將其放置而不是警報
var example = document.getElementById('example');
example.value = linky; // set the value of an input
example.src = linky; // set the source of an image
example.innerHTML = linky; // Set as content of a div/block-element
example.href= linky; // set target for a anchor
給您的文本字段一個ID(例如URL),並使用document.getElementById('URL').value = linky;
您需要通過id或class選擇輸入字段,並將值設置為返回的URL。 在以下情況下,我們使用ID,因此無論輸入內容的ID標簽是什么。
<script type="text/javascript">
function getSnap(linky){
var elem = document.getElementById("myInput");
elem.value = linky;
}
</script>
<input id="myInput" />
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.