SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict
    Join Date
    Nov 2005
    Posts
    396
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Loading Data In a TextBox Thru Ajax

    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.

  2. #2
    SitePoint Guru
    Join Date
    Aug 2009
    Posts
    669
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  3. #3
    SitePoint Addict
    Join Date
    Nov 2005
    Posts
    396
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's my code in creating dynamic textbox
    Code:
    <?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">&nbsp;</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>";
                    }
    ?>

  4. #4
    SitePoint Guru
    Join Date
    Aug 2009
    Posts
    669
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  5. #5
    SitePoint Addict
    Join Date
    Nov 2005
    Posts
    396
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That is already php...

  6. #6
    SitePoint Guru
    Join Date
    Aug 2009
    Posts
    669
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Erm, no it's using [CODE] tags. I've just hit the quote button on your code and seen them myself

    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 Code:
    //Demonstation
    $Test 'This is a test string';

    print 
    $Test
    Also the box showing your code clearly says Code: - Not PHP Code like my demo


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •