0

while clicking the button i want to check the array field value is null or not

code

function renderblock(){
         alert('jjj');
         var result = '{!filterArray}';
           alert(result );
  } 

Alert result ::filterArray values :

[filterField:[label=AccountName, searchFieldName=FULL_NAME, searchValue=]], [filterField:[label=City, searchFieldName=PRIM_CITY, searchValue=test]], [filterField:[label=Country, searchFieldName=PRIM_COUNTRY_NM, searchValue=]], [filterField:[label=Street Address, searchFieldName=PRIM_ADDR_LN_1, searchValue=]], [filterField:[label=State/Province, searchFieldName=PRIM_STATE, searchValue=]], [filterField:[label=Zip/PostalCode, searchFieldName=PRIM_POSTAL_CD, searchValue=]]

In the controller my array value is :

[filterField:[label=AccountName, searchFieldName=FULL_NAME, searchValue=]], [filterField:[label=City, searchFieldName=PRIM_CITY, searchValue=test]], [filterField:[label=Country, searchFieldName=PRIM_COUNTRY_NM, searchValue=]], [filterField:[label=Street Address, searchFieldName=PRIM_ADDR_LN_1, searchValue=]], [filterField:[label=State/Province, searchFieldName=PRIM_STATE, searchValue=test]], [filterField:[label=Zip/PostalCode, searchFieldName=PRIM_POSTAL_CD, searchValue=uma]]

Means am having value for "serachfield" But when i click the button javascript is called first and giving empty values.how to overcome this ?

In this array i want to check atleast one searchvalue attribute is filled or not ..Please help

0

1 Answer 1

2

I suggest using JSON serialize string in apex

public String getJsonArray()
{
  return JSON.serialize(filterArray);
}

and again in VF page use

<script>

    var arraylist = JSON.parse('{!JsonArray}');
    for(var i = 0; i<arraylist.length; i++)
    {
      console.log(arraylist[i]); //check here field null or not
    }

</script>
2
  • could you please review my question again.I just edited now
    – sonu
    Apr 27, 2017 at 11:49
  • when you click on button and call the apex method. you have rerender in VF page to get the updated values @ramu
    – Ratan Paul
    Apr 27, 2017 at 12:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .