Karthik Karthik - 3 months ago 8x
HTML Question

Dynamically assign values to select tag using Xquery

I tried drop down using

<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="opel">Opel</option>
<option value="audi">Audi</option>

It is working well. Instead of hard-coded values , I would like to dynamically assign values from another



So I will have list of countries from the above code that should go to select tag of HTML


Try an XQuery FLWOR expression like:

  for $country in /leader/country/string(.)
  return <option value="{$country}">{$country}</option>

While XPaths over the database are useful for getting started, it's good to learn the Search API or cts:search() to query with good performance over large datasets.

Hoping that helps,