Search code examples
javascriptjqueryatg

How to pass javascript/jQuery script in dsp param tag


I am using ATG and I'm passing dsp include tags, where inside I'm passing dsp param tags

<div id="page1">
    <span id="nameVal"></span>
    <dsp:include page="/name.jsp">
        <dsp:param name="age" value="${currentAGE}" />
        <dsp:param name="name" value="" />
    </dsp:include>
</div>

and In my jQueryfile, I am writing as -

if($("#page1").length > 0){
    $('#nameVal').text('akshay');
}

I want to access the nameVal value which I'm getting from jQuery in <dsp:param name="name" value="" /> as soon as my page1 div loads.

If the dsp include tags can be accessed after the page load and then access the data it can also work. Please help.


Solution

  • Try selecting by the name attribute and setting the value with val():

    if($("#page1").length > 0){
        $('#page1 [name="name"]').val('akshay');
    }