Pages

Showing posts with label Form Submission Using JavaScript in Liferay. Show all posts
Showing posts with label Form Submission Using JavaScript in Liferay. Show all posts

Saturday, 14 April 2012

Form Submission Using JavaScript


<portlet:actionURL var="formDetailsUrl">
           <portlet aram name="customParam" value="nothing"/>
</portlet:actionURL>


<form name="detailForm" method="post" onsubmit="callFormDetails()">
   <select id="topic" name="topic" >
     <option ${topic=='1' ? 'selected' : ''} value="1">ONE   </option>
      <option ${topic=='2' ? 'selected' : ''} value="2">TWO    </option>
                          
</select> 
  <input type="submit" value="submit">
</form>   




<script type="text/javascript">
           function callFormDetails (contID)
           {
                var submitURL ='${formDetailsUrl}';
                var topic     = document.getElementById("topic");
                submitURL     = submitURL.replace("nothing",topic);
                document.detailForm.action=submitURL;
                document.detailForm.submit();
           }
</script>


NOTE : In the javascript we can change the parameter for the URl we define. As this helps us in having control in sending dynamic parameters directly in the URl