maryam.eng
چهارشنبه 18 شهریور 1394, 09:32 صبح
سلام
من ی select نوشتم میخواسم هر بار که روی یکی از گزینه ها کلیک میکنم مقدار آن گزینه در یک متغییر ریخته بشه البته به شرطی که اولین گزینه از select نباشه
اینم کد
<select id="select1" name="listOfSubject" onclick="f1();" >
<c:forEach var="row" items="${result.rows}">
<option ><c:out value="${row.subject_note}"/> </option>
</c:forEach>
</select>
اینم کد جاوا اسکریپ:
function f1(){
var e = document.getElementById("select1");
if(e.options[e.selectedIndex]>=1){
var str = e.options[e.selectedIndex].text;
document.getElementById("bottom5").value = str;
alert(str);
}
من ی select نوشتم میخواسم هر بار که روی یکی از گزینه ها کلیک میکنم مقدار آن گزینه در یک متغییر ریخته بشه البته به شرطی که اولین گزینه از select نباشه
اینم کد
<select id="select1" name="listOfSubject" onclick="f1();" >
<c:forEach var="row" items="${result.rows}">
<option ><c:out value="${row.subject_note}"/> </option>
</c:forEach>
</select>
اینم کد جاوا اسکریپ:
function f1(){
var e = document.getElementById("select1");
if(e.options[e.selectedIndex]>=1){
var str = e.options[e.selectedIndex].text;
document.getElementById("bottom5").value = str;
alert(str);
}