sirGE
February 16, 2011, 12:46pm
1
In my form I dynamically created a textbox, therefore an array of textbox. If a user select an option into a combo box, data will be retrieved in the database an will be displayed on the dynamically created textboxes.
My problem is, how am I be able to display the data into these array of textbox using AJAX, can anyone help me. Thanks in advance.
I think I vaguely understand what you’re saying but you’re not showing any source code
If you can show us that, it might give us a clearer picture.
sirGE
February 16, 2011, 9:25pm
3
Here’s my code in creating dynamic textbox
<?php
$query = "SELECT details FROM award WHERE id=$awardid";
$result = mysql_query($query);
$award = mysql_fetch_array($result);
?>
<div id="heading">::CRITERIA FOR <?php echo $award['details']; ?>::</div>
<div id="entrybody">
<div class="entryheading"> </div>
<form method="post">
<label style="width: 200px; float: left; padding-left: 5px; text-align: right; margin-top: 5px;">Contestant:</label>
<select name="cboContestant" style="font-weight: bold;" >
<option value=""></option>
<?php
$query = "SELECT id, contestantno, contestantname FROM contestants WHERE competitionid='$_SESSION[competitionid]'";
$result = mysql_query($query);
while($contestant = mysql_fetch_array($result))
{
echo "<option value='$contestant[id]' ";
if($_POST['cboContestant']==$contestant['id'])
echo "selected=selected>#$contestant[contestantno] $contestant[contestantname]</option>";
else
echo ">#$contestant[contestantno] $contestant[contestantname]</option>";
}
?>
</select>
<input type="submit" class="buttons" value="View Score" name="cmdViewScore" id="cmdViewScore" />
<br class="br" />
<?php
$query = "SELECT id, criteria, percentage FROM subcriteria WHERE awardid=$awardid";
$result = mysql_query($query);
if(mysql_num_rows($result)>0)
{
echo "<table style='border: 1px solid #000; border-collapse: collapse; margin: 10px;'>";
echo "<tr>
<td style='border: 1px solid #000; background: #CCC; font-weight: bold; width: 500px; text-align: center'>Criteria</td>
<td style='border: 1px solid #000; background: #CCC; font-weight: bold; width: 50px; text-align: center'>Value</td>
<td style='border: 1px solid #000; background: #CCC; font-weight: bold; width: 50px; text-align: center'>Percentage</td>
</tr>";
while($criteria = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td style='border: 1px solid #000; font-weight: bold;'>$criteria[criteria]</td>";
echo "<td style='border: 1px solid #000; text-align: center;'><input type='text' name='txtInput[]' id='txtInput[]' class='entry' size='5'".
"maxLength='3' onKeyPress='return NumericEntryOnly(event)' /></td>";
$criteriaid[] = $criteria['id'];
echo "<td style='border: 1px solid #000; text-align: center;'>$criteria[percentage]%</td>";
echo "</tr>";
}
echo "<tr><td colspan='3'>";
echo "<input type='submit' name='cmdSave' id='cmdSave' value='Save' class='buttons' style='float: right;' />";
echo "</td></tr>";
echo "</table>";
}
?>
As that starts with php, could you change the tags to php tags please? - Makes it a bit easier to read (it formats and colors the text differently).
Thanks.
Erm, no it’s using
tags. I've just hit the quote button on your code and seen them myself :rolleyes:
PHP tags look like this
```php
. You've not used them. I've asked you once already, I won't ask again. In case you're wondering what the fuss is about PHP tags do this and make it much easier to read:
```php
//Demonstation
$Test = 'This is a test string';
print $Test;
Also the box showing your code clearly says Code: - Not PHP Code like my demo