1
I would like to know if it is possible to create dynamic selects on a page, identical to the free market advertising register.
In fact, I’m trying to create an integration with exactly their routine. I’m having difficulties with the categories. Depending on the type of the parent category, it is necessary to open a new select with the child categories and so on. There is no way to know the number of items nor the hierarchy.
I selected the main category that way:
<div id="categoria">
<label>Categoria</label>
<select id="cmbCategoria" class="sub">
<option>Carregar Categoria</option>
</select>
<input type="button" value="Carregar Categoria" id="btnCategoria" class="botao"/>
</div>
From what I’ve researched, to include a select would be that way:
$("#categoria" ).append("<select class='sub' id="+id+"><option value>Subcategoria</option></select>");
Would there be an easier way? I can get the id of the dynamic select?
The idea seems right, but where will you pull this data? Via Ajax?
– Sam
Ideally you would already leave this data saved in a variable in Javascript, so you would save your server resources, and display it in HTML according to what the user was selecting.
– Leonardo Patricio