I have a modification of the dynamic code here embedded within a PHP form, with span elements such as
<span level='0'></span>
<span level='1'></span>
<span level='2'></span>
in the form.
Each span will contain a <select>
dropdown that needs to be POSTed
Each span is filled using a JS function exactly like the one in the link, which calls the shown ajax.php file to fill the dropdowns.
These values do not POST with my form, presumably because SPANs may not be processed as part of the POST array. Is there a way I can modify this to work?
I haven't checked the details of the link, but it seems you could use a form element such as instead of <span>
to post the data that you need, and just use JS to set the value of this element accordingly.
Edit: An example. I may be misinterpreting your question. What is the data that is important to you - The level at which the user selected? So, if I make a selection from the <span level='1'></span>
<select>
, you need to know that I chose level 1? In this case, since you're pulling that from the DB through AJAX anyway, I would check it on the server side using PHP to determine the chosen level. Otherwise, you can do something similar to the following.
Note: This will only set the hidden element to the level of the last changed <select>
.
<form>
<span level="0">
<select onchange="javascript: $('#input_span_level').val('0');"></select>
</span>
<span level="1">
<select onchange="javascript: $('#input_span_level').val('1');"></select>
</span>
<input id="input_span_level" type="hidden" name="span_level" value="-1" />
</form>