You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Neth <ne...@100.ph> on 2003/03/12 10:36:11 UTC
html:options and javascript
Hello,
I have an existing application which i converted into struts,
however i'm having some problem with regards to option with javascript.
The picture of the user should be reflected whenever his/her user id is
selected from the drop down box.
Below is the working application:
<script language="javascript">
function showimage()
{
if (!document.images)
return
document.images.pictures.src=document.mygallery.userId.options[document.mygallery.userId.selectedIndex].value;
}
</script>
<select size="1" name="userId" onChange="showimage()">
<% for (int i=0;i<LoginManager.getNoUsers();i++) {
pix = "pix\\" + LoginManager.getusers(i) + ".jpg";
%>
<option value="<%=pix%>"><%=LoginManager.getusers(i)%></option>
<% } %>
</select>
<p><br>
</td>
<td align="center">
<% if(LoginManager.getNoUsers()!=0){
init = "pix\\" + LoginManager.getusers(0) + ".jpg";
}
%>
<img src="<%=init%>" name="pictures">
</td>
Conversion into struts not working
<script language="javascript">
function showimage(){
if (!document.images)
return
document.images.pictures.src=document.forms.userId.options[document.forms.userId.selectedIndex].value;
// error here
}
</script>
<html:select property="userId" style="width:195px" size="1"
onclick="javascript:showimage()">
<option value="pix\\Diane.jpeg" selected></option>
<html:options collection="users" property="userId"
labelProperty="userId"/>
</html:select>
<img src=" " name="pictures">
Thanks
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org