나는이 다음 HTML 코드를 생성하는 형태로이 아이들을 모두 추가쓰기 값
var form = document.getElementById("form");
var thirdElement = document.createElement("select");
var thirdElementOp1 = document.createElement("option");
thirdElementOp1.value = "--IDEAS--";
var thirdElementOp2 = document.createElement("option");
thirdElementOp2.value = "Random";
var thirdElementOp3 = document.createElement("option");
thirdElementOp3.value = "--FUN--";
var thirdElementOp4 = document.createElement("option");
thirdElementOp4.value = "Reflective";
thirdElement.appendChild(thirdElementOp1);
thirdElement.appendChild(thirdElementOp2);
thirdElement.appendChild(thirdElementOp3);
thirdElement.appendChild(thirdElementOp4);
form.appendChild(thirdElement);
이 코드가 있습니다
<form id="form" action="home.php" method="post">
<select>
<option value="TheJSGeneratedValue"></option>
<option value="TheJSGeneratedValue"></option>
<option value="TheJSGeneratedValue"></option>
<option value="TheJSGeneratedValue"></option>
</select>
</form>
내 문제가 있다는 것입니다에게 이 값들은 드롭 다운 메뉴에 표시 될 수 있도록 다음과 같이 태그 내부에 써야합니다.
JavaScript에서이 작업을 수행 할 수있는 방법이 있습니까? 나는 jQuery 응답을 받아 들인다. 자바 스크립트를 고맙게 생각한다. 아마도 thirdElementOp1.valueInside = "Value"
또는 그와 비슷한 것일 수도있다.
이 방법이 효과가 있습니까? http://stackoverflow.com/a/14827245/3264286 – Delorian