Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2008
    Posts
    682
    Thanks
    114
    Thanked 2 Times in 2 Posts

    jquery change function

    not sure if I"m doing this correctly so seeing who can see or tell me if I'm doing this wrong.

    Say you chose an option from select box it would go into the events table and see that there's not been another event with that id so it'll return 1 and put it inside the text field called Label and when the user fills out the rest of the form it'll put 1 for the label field in the database table when the form is submitted then say the next week rolls around and the user clicks on that same option again and it goes to the events table and sees that there's an occurance of that show via the matching eventids and grabs all the labels with that matching eventid which at this point is only 1 so it would add 1 to that number and return 2 to the Label form text field.

    form page
    Code:
    $('#eventid').change(function() {
          var eventid = $("select#eventid").val();
          var dataString = 'eventid='+ eventid;
          $.ajax({
            type: "POST",
            url: "processes/booking.php",
            data: eventid,
            success: function(data) {
            $('#label').append(data);
            }
            });  
        });
    
    <div class="field required">
        			<label for="eventid">Select Event</label>
                    <select class="dropdown" name="eventid" id="eventid" title="Select Event">
                    <option value="0">- Select -</option>
                    <option value="0">** Recurring Events **</option>
                    <?php
                        $query = 'SELECT id, eventname FROM eventnames WHERE eventtype = "Recurring"';
                        $result = mysqli_query ( $dbc, $query ); // Run The Query
                        while ( $row = mysqli_fetch_array ( $result, MYSQL_ASSOC ) ) { 
                            print "<option value=\"".$row['id']."\">".$row['eventname']."</option>\r";
                        }
                        ?>
                    <option value="0">** Singular Events **</option>
                    <?php
                        $query = 'SELECT id, eventname FROM eventnames WHERE eventtype = "Singular"';
                        $result = mysqli_query ( $dbc, $query ); // Run The Query
                        while ( $row = mysqli_fetch_array ( $result, MYSQL_ASSOC ) ) { 
                            print "<option value=\"".$row['id']."\">".$row['eventname']."</option>\r";
                        }
                        ?>
                    <option value="0">** Pay Per View Events **</option>
                    <?php
                        $query = 'SELECT id, eventname FROM eventnames WHERE eventtype = "Pay Per View"';
                        $result = mysqli_query ( $dbc, $query ); // Run The Query
                        while ( $row = mysqli_fetch_array ( $result, MYSQL_ASSOC ) ) { 
                            print "<option value=\"".$row['id']."\">".$row['eventname']."</option>\r";
                        }
                        ?>
                    </select>
        			<span class="required-icon tooltip" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span>
        		</div>
                <div class="field required">
    				<label for="label">Event Label</label>
    				<input type="text" class="text" name="label" id="label" title="Label" readonly="readonly" />
                    <span class="required-icon tooltip" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span>
    			</div>
    processes/booking.php
    PHP Code:
    $eventid = (int)$_GET['eventid'];
    $result mysqli_query("SELECT * FROM `events` WHERE `event_id` = '$eventid'");
    $list mysqli_num_rows($result);
    $label $list 1
    Last edited by CoolAsCarlito; 12-14-2010 at 09:18 PM.

  • #2
    Regular Coder
    Join Date
    Jun 2008
    Posts
    682
    Thanks
    114
    Thanked 2 Times in 2 Posts
    One problem was my data: eventid when it should have been data: dataString. That being said now I have it posting the correct parameter to the process page and now I need to figure out when it performs the processes page coding to send BACK the label variable.


  •  

    Posting Permissions

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