JavaScript how to pass javascript variable into liquid markup? pass javascript variable to php,pass javascript variable to html,

I have a value from JavaScript:

  var customerID = document.getElementById("CustomerID").value;

Now I want query the firstName, lastName from module data, based on that customerID variable.

    {module_data resource="customers" version="v3" fields="id,firstName,lastName,titleType,customerTypeId,ratingTypeId" skip="0" limit="10" order="lastName" collection="selected-data"}  
    {% for item in selected-data.items %}
    {% if item.id == 10393092%}
     document.getElementById("CAT_Custom_15").setAttribute("value","{{item.titleType.label}}") ;
     document.getElementById("CAT_Custom_14").setAttribute("value","{{item.firstName}}");                        
     document.getElementById("CAT_Custom_4").setAttribute("value","{{item.lastName}}");
    {% endif %}
    {% endfor %}

How should I write the where condition? Whne I assign instant value that 10393092 in my code above. It is working fine. but I need assign the variable equal to item.id(like item.id == customerID). Anyone can help? Thank you so much

Answer:1

What you are asking for is not possible. Liquid generates a static page, which is then stored on your web server. When a user navigates to your site, the pre-generated page is sent to them. Then the JavaScript in it may execute. At this point, it is impossible to do anything in Liquid. You should be looking for a pure JavaScript solution.

Answer:2

I want to use jQuery to look for some text and it exists I want to hide it. So if : Yes exists it should be hidden. HTML: <div class="listing_detail col-md-4"><strong>Living Room:</...

I want to use jQuery to look for some text and it exists I want to hide it. So if : Yes exists it should be hidden. HTML: <div class="listing_detail col-md-4"><strong>Living Room:</...

  1. hide search text in datatable
  2. jquery datatable hide search text box
  3. hide text search

I have an image in the center of my webpage. Once the user scrolls and the image hits the top of the window, I am attempting to fix the image to the top of the page so that it scrolls with the page. ...

I have an image in the center of my webpage. Once the user scrolls and the image hits the top of the window, I am attempting to fix the image to the top of the page so that it scrolls with the page. ...

I want to set date and time to 2016-05-11T00:00:00.000Z var date = new Date(2016,4,12,0,0,0,0); but instead of showing Date 2016-05-11T00:00:00.000Z its giving Date 2016-05-11T19:00:00.000Z I want ...

I want to set date and time to 2016-05-11T00:00:00.000Z var date = new Date(2016,4,12,0,0,0,0); but instead of showing Date 2016-05-11T00:00:00.000Z its giving Date 2016-05-11T19:00:00.000Z I want ...

  1. javascript setting date
  2. javascript setting date format
  3. javascript date setting time zone
  4. javascript date setting time
  5. javascript datepicker setting date

I need to add CSS properties on each element of a collection with jQuery. Any suggestions? var jsonCss = { "color": "#555555", "font-weight": "bold", "text-align": "left" }; var $...

I need to add CSS properties on each element of a collection with jQuery. Any suggestions? var jsonCss = { "color": "#555555", "font-weight": "bold", "text-align": "left" }; var $...

  1. properties collection in java
  2. properties collection in spring
  3. properties collection in c#
  4. properties in collection
  5. properties in collection javatpoint
  6. collection properties in blue prism