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
    New Coder
    Join Date
    Dec 2005
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Adding onchange code

    Hi Everyone,

    I would like to add this code in the script bellow "ONCHANGE="search.value=this.options[this.selectedIndex].text"
    I'm not sure how to handle this, can someone help me?
    Thanks


    <?PHP
    @ $db = mysql_pconnect(localhost, xxxx_xxxx, xxx);
    if (!$db) {
    print "Failed to connect to the database. Please try again later.\n";
    exit;
    }
    mysql_select_db(xxx_xxx);
    $sql = "SELECT * FROM `seedling` ORDER BY `Available_Images` ASC";
    if (!(@ $result = mysql_query($sql))) {
    print "There was an error running your query:<p>\n". $sql . "<p>\n";
    }
    print '<select name="Available_Images"><br>\n';
    print '<option value=""> Choose One ';
    while ($row = mysql_fetch_row($result)) {
    $id = $row[0];
    $Available_Images = $row[24];

    print "<option value=\"$id\"";
    if ($_REQUEST["Available_Images"] == $id) { print " selected"; }
    print "> $Available_Images <br>\n";
    }
    print '</select>';

    ?>

  • #2
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,773
    Thanks
    19
    Thanked 155 Times in 146 Posts
    I dont't know if your javascript works, but this is how you include the event handler:

    PHP Code:
    print '<select name="Available_Images" onChange="search.value=this.options[this.selectedIndex].text;"><br>\n'
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!


  •  

    Posting Permissions

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