Below i have pasted my piece of javascript code here
1)
function showCustomerName(dropdown) {
var selectedCustomer = dropdown.options[dropdown.selectedIndex].value;
var currentCustomer = document.getElementById('currentCustomer');
alert(selectedCustomer);
var context = document.forms[0].context.value;
document.forms[0].mode.value = "UPDATE";
document.forms[0].custName.value = selectedCustomer ;
document.forms[0].action=context+"/updateReportDetail.do";
document.forms[0].method="POST";
document.forms[0].submit();
}
2)
function showCustomerID(dropdown) {
var currentCustomer = document.getElementById('currentCustomer');
var selectedCustomerID = dropdown.options[dropdown.selectedIndex].value;
alert(selectedCustomerID);
var context = document.forms[0].context.value;
document.forms[0].mode.value = "UPDATE";
document.forms[0].custName.value = currentCustomer;
document.forms[0].custID.value = selectedCustomerID ;
document.forms[0].action=context+"/updateReportDetail.do";
document.forms[0].method="POST";
document.forms[0].submit();
}
<select id="currentCustomer" onchange="showCustomerName(this)">
<c:forEach var="Customer" items="${listCustomer}" >
<option value="<c:out value="${Customer}" />"><c:out value="${Customer}" />
</option>
</c:forEach>
</select>
<select id="currentCustomerID" onchange="showCustomerID(this)">
<c:forEach var="CustomerID" items="${listCustomerID}" >
<option value="<c:out value="${CustomerID}" />"><c:out value="${CustomerID}" />
</option>
</c:forEach>
</select>
the above code is working fine. The thing is i need to retrieving value from "showCustomerName()" to "showCustomerID()" script .
In "showCustomerID()" script method i am retrieving "showCustomerName()" methods value as object
var currentCustomer = document.getElementById('currentCustomer');
how to retrieve it as a value? i dont want to retrieve as object
please help me guys.