By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,573 Members | 903 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,573 IT Pros & Developers. It's quick & easy.

How Can I show the link based on the value selected in the drop down?

P: 1
Hi to all,

I have written one jsp file. In that file, I have one drop down which contains list of request name (like student name) based on the selected value within drop down I will display the link 'Request Details(ie, Student Details)' besides that drop down.


This link is used to navigate to view the request information(ie, Student Information.)

I have written the code as follows :


In My Action Class :

Expand|Select|Wrap|Line Numbers
  1. if(interviewForm.getRequisitionName()!=null){
  2.             long reqId = Long.parseLong(interviewForm.getRequisitionName());            
  3.             request.setAttribute("requisitionId",reqId);
  4.             //System.out.println("Req Id : "+reqId);
  5.         }else{
  6.             //System.out.println("Requisition Name"+interviewForm.getRequisitionName());
  7.             request.setAttribute("requisitionId","3");
  8.             //System.out.println("In Action : "+request.getAttribute("requisitionId"));
  9.         }
  10.  
In JSP:

javascript:

Expand|Select|Wrap|Line Numbers
  1. function showlink(){
  2.         alert( 'Value: ' + document.getElementById("requisitionName").value);        
  3.           //resetVal();
  4.           disableOrEnableMarks();
  5.           var candidateId = document.getElementById("id").value;    
  6.           document.InterviewScheduleForm.action ="InterviewSchedulerAction?id="+candidateId;
  7.         document.InterviewScheduleForm.submit();
  8.     }
  9.  

Expand|Select|Wrap|Line Numbers
  1. <tr>
  2.                         <td class="Content" width="30%">
  3.                             <bean:message key="interviewscheduler.field.interviewRequisitionName" />
  4.                             :
  5.                             <span class="reddot"> *</span>
  6.                         </td>
  7.                         <td width="30%">
  8.                             <input type="hidden" name="id" value="<%=candidateId%>">
  9.                             <logic:present name="requisitionNameList" scope="request">
  10.                                 <html:select property="requisitionName" styleClass="select1" onchange ='javascript:showlink();'>
  11.                                     <html:options collection="requisitionNameList" property="id"
  12.                                         labelProperty="requisitionName"/>
  13.                                 </html:select>
  14.                             </logic:present>
  15.  
  16.                         </td>                        
  17.                         <%                                            
  18.                         int requisitionId = Integer.parseInt(request.getAttribute("requisitionId").toString());
  19.                         if(requisitionId!=3){%>
  20.                             <td><a href="javascript:showrequisitiondetails()">&nbsp;Show Requisition Details</a></td>
  21.                             <td width="20%">
  22.                                 &nbsp;
  23.                             </td>
  24.                         <% } %>
  25.                     </tr>
  26.  

Can you plzzzzzzzz help me..........

Thanks in advance
Sep 9 '08 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
Put a link next to the drop down and set the href in showLink(), e.g.
Expand|Select|Wrap|Line Numbers
  1. // get requisite name value...
  2. // get link
  3. var link = document.getElementById("linkID").href = url + "?val=" + encodeURIComponent(reqVal);
Sep 15 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.