How to pass reference field value from html to client script of ui page?

Ankita Kolhe
Tera Contributor

Hi Community,

 

How to pass reference field value from html to client script of ui page?

 

HTML code:-

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
 
<label for="${jvar_app_query}" onclick="" dir="">${gs.getMessage("Parent Entity")}</label>
<g:ui_reference style="width:20px" name="QUERY:active=true" id="entity_name" table="x_kpm79_kpmgi_iogc_kpmgi_iogc_entity_management_base" />
<button type="button" class="button button1" style="background-color: #04AA6D" onclick="test()">Ok</button>
</j:jelly>
 
Client Script:-
function test(){
    alert('test '+$j('entity_name'));
}
 
Alert message is not showing correct value.
 
Could someone please help on this?
 
Thanks,
Ankita

 

 

1 ACCEPTED SOLUTION

@Ankita Kolhe 

Please add below code in HTML:

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<label for="${jvar_app_query}" onclick="" dir="">${gs.getMessage("Parent Entity")}</label>
<g:ui_reference style="width:20px" query="active=true" name ="entity_name" id="entity_name" table="x_kpm79_kpmgi_iogc_kpmgi_iogc_entity_management_base" />
<button type="button" class="button button1" style="background-color: #04AA6D" onclick="test()">Ok</button>
</j:jelly>

 

And below code in client script :

function test() {
var entityName = $("entity_name").value;
alert(entityName);
}

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

 

Please mark correct/helpful if this helps you!

View solution in original post

3 REPLIES 3

Unique45
Mega Sage

Hello @Ankita Kolhe,

 

Please use below code in the client script:

var entityName= $("entity_name").value;

alert(entityName);

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

 

Please mark correct/helpful if this helps you!

Hi @Unique45 ,

Thanks for your response. However its not working.

 

 

@Ankita Kolhe 

Please add below code in HTML:

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<label for="${jvar_app_query}" onclick="" dir="">${gs.getMessage("Parent Entity")}</label>
<g:ui_reference style="width:20px" query="active=true" name ="entity_name" id="entity_name" table="x_kpm79_kpmgi_iogc_kpmgi_iogc_entity_management_base" />
<button type="button" class="button button1" style="background-color: #04AA6D" onclick="test()">Ok</button>
</j:jelly>

 

And below code in client script :

function test() {
var entityName = $("entity_name").value;
alert(entityName);
}

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

 

Please mark correct/helpful if this helps you!