Reputation: 1
I am tying to alert the value of namesEmp variable and i get this Ljava.lang.String;@3433205b as result.
my javacsript:
function getNames(names) {
var namesEmp = "";
var namesEmpText = "";
for(i=0;i<names.length;i++) {
if(names.options[i].selected) {
namesEmp = names.options[i].value;
namesEmpText = names.options[i].text;
alert(namesEmp);
alert(namesEmpText);
}
}
}
and here is my HTML:
<tr style="position:relative;left:19;top:1;display:none;">
<td style="position:relative;top:1;text-align:right;">Country:</td>
<td>
<select id="namePay" name="namesPay" onChange="setTimeout('getNames(f.name)',1);">
<%
String namesDesc = "";
if(namesList.size()>0){
for(int i=0;i<namesList.size();i++){
String[] namesValues = ((String)namesList.get(i)).split("~");
NamesText = namesValues[0];
%>
<option value="<%=namesValues%>"><%=NamesText%>
<%}
}%>
</select>
</td>
</tr>
When I alert namesEmpText, i get the the correct result. Any help would be appreciated.
Upvotes: 0
Views: 74
Reputation: 107508
The issue is here:
<option value="<%=namesValues%>"><%=NamesText%>
^
You are trying to render the Java object namesValues
(a string array), as a select option value. The JVM doesn't know how to automatically convert an array to a string, so it renders the type name for it instead. Did you mean to include an indexer to that array? For example:
<option value="<%=namesValues[1]%>"><%=namesValues[0]%>
Upvotes: 1