struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Neth <nen...@100.ph>
Subject html:options and javascript
Date Wed, 12 Mar 2003 09:36:11 GMT
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


Mime
View raw message