私はjavascriptについて知りたいと思っています。入力フィールドに文字列を入力するような値のdropdownmenu idで値が変更されたとき、私がやりたいことは非常に簡単です。項目がドロップダウンメニュー(html、javascript)で変更されたときに入力フィールドを入力してください
これはHTMLです:
<div>
<input type="text" id="field_id" placeholder="Using..." style="width: 400px">
<select style="width: 180px" onchange="Test()">
<option value="" disabled selected>Select</option>
{% for stuff in stuffs%}
<option value="{{stuff}}">{{stuff}}</option>
{% endfor %}
</select>
</div>
そして、同じドキュメント内のjavascript:
<script>
function Test()
{
document.getElementById(field_id).text = "asdsads";
}
</script>
入力フィールドが文字列 "asdsads" で満たされて文句を言わないのはなぜ?
あなたは[あなたを確認しましたエラーのコンソール?](http://stackoverflow.com/documentation/javascript/185/hello-world/714/using-console-log)覚えておいてください: 'document.getElementById'は' 'string''をとります。 –
try document.getElementById( "field_id")。text = "asdsads"; – Ram