SitePoint Sponsor

User Tag List

Results 1 to 9 of 9

Thread: Option Values

  1. #1
    SitePoint Zealot txt3rob's Avatar
    Join Date
    Jul 2013
    Location
    Liverpool UK
    Posts
    199
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Option Values

    below i have some code that will post the txtid to my script that will query what i need to cause it's not posting it with an id my sent.php script keeps failing.

    how would i set the dropdown an id of say messageid

    PHP Code:
    <form action="./include/sent.php" method="post" id="smsstatus"> 
    <select id="messageid">
      <option value="<?php echo (''.$row['txtid'].'') ;?>"><?php echo (''.$row['to'].'') ;?></option>
    </select>
    <input name="status" data-role="button" data-inline="true" type="submit" value="submit" />
    </form>
     <div id="result"></div>
    </body>
    </html>

  2. #2
    SitePoint Addict bronze trophy
    Join Date
    Sep 2005
    Posts
    317
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Can we see the sent.php code too?

  3. #3
    SitePoint Zealot txt3rob's Avatar
    Join Date
    Jul 2013
    Location
    Liverpool UK
    Posts
    199
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php
    //initilize PHP
    if ( isset ( $_POST['status'] ) ) //If submit is hit
    {
    // Message Details
        
    $message_id$_POST['messageid'];
    echo (
    ''.$messageid.'');
    ?>
    sent.php does more but this is the essential bit

  4. #4
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,500
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Do a print_r($_POST); in sent.php, and see what exactly is being sent

  5. #5
    SitePoint Zealot txt3rob's Avatar
    Join Date
    Jul 2013
    Location
    Liverpool UK
    Posts
    199
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    when i run firebug it shows that the txtid is being set but no parameter set

  6. #6
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,136
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Okay, your issue is 1 of 2 likely places. 1) $row['txtid'] is blank, thus the value of your drop down option is blank. 2) the data isn't getting to sent.php or being read properly in sent.php.

    So start with your dropdown. View the Source of the page and make sure the drop down actually has a value (that isn't spaces/blank).
    Then submit the form after adding var_dump($_POST); to your sent.php so you can see what data is being received by sent.php.

    From what you've done so far and what you have provided us, my guess is $row['txtid'] doesn't contain what you think it does.

  7. #7
    SitePoint Zealot txt3rob's Avatar
    Join Date
    Jul 2013
    Location
    Liverpool UK
    Posts
    199
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    when checking the html the value field is populated.
    this is what i see via firebug


    where the long number is that is the value i wish to capture.


    i get the following if i print the $post

    array(1) { ["status"]=> string(6) "submit" }

  8. #8
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,136
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Bingo!

    HTML Code:
    <select id="messageid"> 
      <option value="<?php echo (''.$row['txtid'].'') ;?>"><?php echo (''.$row['to'].'') ;?></option> 
    </select>
    See the issue? That's okay, we all missed it multiple times. You defined an ID, but you never gave it a NAME!

    HTML Code:
    <select id="messageid" name="messageid"> 
      <option value="<?php echo (''.$row['txtid'].'') ;?>"><?php echo (''.$row['to'].'') ;?></option> 
    </select>
    That should solve your issue.

  9. #9
    SitePoint Zealot txt3rob's Avatar
    Join Date
    Jul 2013
    Location
    Liverpool UK
    Posts
    199
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cpradio - my friend you are spot on with that fix!

    thank you very very much!


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
  •