Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplay data using ajax when two fields are selected Liferay
    primarykey
    data
    text
    <p>I am using ajax for displaying data. When I select a name from the drop box I use ajax and data of the selected name is displayed. I use the follwing script for this:</p> <pre><code> &lt;script&gt; $(document).ready(function(){ $('#absentEmployeeName').change(function(){ alert($(this).val()); var absentEmployeeName = ($(this).val()); alert("hi"); if ($(this).val() != '') { $.ajax({ url : '${sendEmpNameResourceURL}', data : { &lt;portlet:namespace /&gt;absentEmployeeName : $(this).val() }, type: 'POST', dataType : "json", success : function(jsonArray) { alert(jsonArray); $('#myUniqueLabelId').html( jsonArray[0]+ jsonArray[1] + jsonArray[2]); } }); } }); }); &lt;/script&gt; </code></pre> <p>Where <strong>absentEmployeeName</strong> is the id of the dropbox where I select the name whose information is displayed using ajax.</p> <p>What I want to do now is besides selecting the name from dropbox , I also want to select date; and based on date and name(from the dropbox) selected I want to display the data. How should I pass both the ids(of dropbox and date) to the serveresource function so that I can display the data?</p> <p>In the above script:</p> <pre><code>$('#absentEmployeeName').change(function() </code></pre> <p>I am passing id of only dropbox. How to pass ids of two fields?</p> <p>EDIT:</p> <p>hERE IS THE SNIPPET OF MY HTML:</p> <pre><code> &lt;script&gt; $(document).ready(function(){ $('#absentEmployeeName').change(function(){ alert($(this).val()); var absentEmployeeName = ($(this).val()); alert("hi"); if ($(this).val() != '') { $.ajax({ url : '${sendEmpNameResourceURL}', data : { &lt;portlet:namespace /&gt;absentEmployeeName : $(this).val() }, type: 'POST', dataType : "json", success : function(jsonArray) { alert(jsonArray); $('#myUniqueLabelId').html( jsonArray[0]+ jsonArray[1] + jsonArray[2]); } }); } }); }); &lt;/script&gt; &lt;body&gt; &lt;select id="absentEmployeeName" name="absentEmployeeName" &gt; &lt;%List&lt;Employee&gt; EmpList = EmployeeLocalServiceUtil.getEmployees(-1,-1); List&lt;LeaveCard&gt; leaveBalList = LeaveCardLocalServiceUtil.getLeaveCards(-1,-1); for(Employee emp : EmpList ) { long empId = emp.getEmpId(); %&gt; &lt;option value='&lt;%=emp.getEmpId() %&gt;' name = "leaveEmp"&gt;&lt;%=emp.getEmpFname()%&gt; &lt;%=emp.getEmpLname()%&gt;&lt;/option&gt; &lt;%} %&gt; &lt;/select&gt; &lt;div id = "empDetails"&gt; &lt;/div&gt; &lt;input type = "date" id = currentDate/&gt; &lt;td colspan=2&gt; &lt;input type="radio" name="forcedabsent" value="LWP"&gt;To be treated as LWP&amp;nbsp;&amp;nbsp; &lt;input type="radio" name="forcedabsent" id = "absenteeEmp"&gt; &lt;label id="myUniqueLabelId"&gt;&lt;/label&gt; to apply for leave&lt;br&gt;&lt;br&gt; &lt;b&gt;Other instructions to Employee/HR&lt;/b&gt;&lt;br&gt; &lt;textarea cols=60 rows=3 name = "markAbsentRemarks" id = "markAbsentRemarks"&gt; &lt;/textarea&gt; &lt;/td&gt; &lt;/body&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload