Foren

Javascript/Ajax

Avinash Vutukuri, geändert vor 12 Jahren.

Javascript/Ajax

New Member Beiträge: 18 Beitrittsdatum: 07.07.11 Neueste Beiträge
Hello,

I have a portlet which contains a form with 5 fields. I have to create a dynamic drop down list where the options of one dropdown field are dependant on the other dropdown field. Can some one let me know how could this be acheived?


I have implemented it by using Javascript/ajax. I have another "jsp" containing the code to communicate with the database and fetch the data which is called Onchangeof the 1st dropdown. But this jsp is not being invoked. Can some one let me know how can this be resolved??


Thank You,
Avinash.
Kavita Gupta, geändert vor 12 Jahren.

RE: Javascript/Ajax

Junior Member Beiträge: 64 Beitrittsdatum: 12.03.08 Neueste Beiträge
Hi Avinash,

Hope below code will help


Jquery:

<script type="text/javascript" language="javascript">
    $(document).ready(function(){
        $("#testLink").click(function(){
            $.post('<%=request.getContextPath()%>/selectOption.jsp', {}, function(data){
                $("#infoValue").html(data);
            })
        });
    });

</script>


Html :
<div id="mainDetails">
    <a href="#" id="testLink">Get Value</a>
    <span id="infoValue"></span>
</div>
thumbnail
Ravi Kumar Gupta, geändert vor 12 Jahren.

RE: Javascript/Ajax

Liferay Legend Beiträge: 1302 Beitrittsdatum: 24.06.09 Neueste Beiträge
I would suggest you to go with either serveResource method or using processAction but with Exclusive mode of portlet. You should be able to get both examples here http://sourceforge.net/projects/ajaxjqueryportl/files/
thumbnail
Sagar A Vyas, geändert vor 12 Jahren.

RE: Javascript/Ajax

Liferay Master Beiträge: 679 Beitrittsdatum: 17.04.09 Neueste Beiträge
Hi Avinash,

For simple understanding you can refer this also : http://www.excession.org.uk/blog/liferay-and-ajax.html

Thanks,
Sagar Vyas
thumbnail
Jignesh Vachhani, geändert vor 12 Jahren.

RE: Javascript/Ajax

Liferay Master Beiträge: 803 Beitrittsdatum: 10.03.08 Neueste Beiträge
Hi Avinash,
you can check this url http://liferaycms.blogspot.com/2011/06/ajax-call-using-jquery-in-liferay.html
Hope this will be usefull