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
    Nov 2002
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    php call fuction oncahnge

    i have dropdown list when the user select it, the code will bring the information that correspond to the selected item:
    PHP Code:
    <?
    // connecting with database
    $db =mysql_connect("localhost","root","");

    //selecting db
    mysql_select_db("project",$db)or die("Unable to select database project");
     
    ?>
    <form name="make" avalue="<?php $PHP_SELF?>  method="post">
    <select name='selitems' onchange='this.make.submit()' >
    <option value = "" >None</option>
    <?
    $sql 
    mysql_query("SELECT item_name FROM items");  
    for (
    $a 0$a mysql_num_rows($sql); $a++) {
     
    $array mysql_fetch_row($sql);
     echo 
    "<option name='$array[0]' value='$array[0]'>".$array[0]."</option>";

    }
    if(
    $value){
        
    $result mysql_query("select * from items where val = $item_name ",$db);
        
    $myrow mysql_fetch_array($result) or die(mysql_error());
     echo 
    "price".$array["a"];

    }
    ?>
    </select>
    </form>

  • #2
    Regular Coder
    Join Date
    Mar 2004
    Posts
    115
    Thanks
    0
    Thanked 0 Times in 0 Posts
    try the below the on change need a form name to submit form and if you have a submit button make sure its not name submit

    echo"<form name=\"form2\" method=\"post\" action=\"".$_SERVER['PHP-SELF']."\">";

    echo "<select name=\"selitems\" onchange=\"document.forms['form2'].submit()\" size=\"10\">";


  •  

    Posting Permissions

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