tags:

views:

372

answers:

2

Hi,

I have a form embedded in a html/smarty template code. Inside a form there is a dropdown box with options populated from db. If you change an option, it calls a php script via onChange event using ajax that creates/populates 2 further dropdowns. This part works fine, but if you submit the whole form (involving original dropdown and the 2 further dynamically created ones) in case of 2 dynamically created drop-downs the key-value pairs are simply not sent to the browser despite that they are inside the tags as well.In other words it sends only the values contained the template itself and not the ones generated into "txtHint1" via ajax.

Thnx

html/template form:

<table border="0" width="600">
<tr>
<form name='form1' id='form1' method='get' action=''>
<td width="80"><h4><b>Source 1:</b></h4></td>
<td>
<select name='host_selection' onChange="showDatet(this.value,'txtHint1')">
{foreach from=$hostlist item="entry"}
<option value={$entry.host}>{$entry.host}</option>
{/foreach}
</select>
</td>
<td>
<div id="txtHint1">
</div>
</td>
</tr>
<tr>
<td>
<button type='submit' name='Submit'>COMPARE!</button>
</td>
<td>
<input type='hidden' name='op' value='hid' />
</td>
</form>
</tr>
</table>

part of php code called via ajax:

echo "<select name='datet_selection" . $fieldID . "'>Test</option>";
foreach ($x->sql->record as $temp) {
 echo "<option value='" . $temp['datet'] . "'>" . $temp['datet'] . "</option>";
}
echo "</select>";
+1  A: 

This may not solve the entire problem, but the dropdowns your are dynamically rendering do not appear to be well-formed. Change:

echo "<select name='datet_selection" . $fieldID . "'>Test</option>";

to

echo "<select name='datet_selection" . $fieldID . "'><option>Test</option>";
Chris Pebble
A: 

I think you also need an ... So you would want:

echo "<select name='datet_selection" . $fieldID . "'><option>Test</option></select>";
Josh Curren