Karthik Karthik - 1 year ago 92
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

Answer Source

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,

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download