Please enable JavaScript to view this site.

Navigation: Advanced topics > Events > Sample events > Appearance

Add a dropdown list box with values for the search

Scroll Prev Next More

 

Add a dropdown list box with specific values.

 

For example, select a car make name from the dropdown list box, and make it so that only the data for the selected car make is displayed.

 

Insert C#/VB.NET code snippet on the Page Designer screen to do so:

 

//create a dropdown box
string str= "<select style='width: 150px; display: inline-block;' class='form-control' onchange=\"window.location.href=this.options[this.selectedIndex].value;\"><option value=\"\">Please select</option>";
 
//select values from the database
string strSQL = "select Make from cars";
dynamic rs = DB.Query(strSQL);
XVar data;
while(data = rs.fetchAssoc())
  str = str + "<option value='../carscars/list?q=(Make~equals~"+data["Make"].ToString()+")'>"+data["Make"].ToString()+"</option>";
str = str + "</select>";
MVCFunctions.Echo(str);

 

 

See also:

Insert code snippet

About Page Designer

Database API