This is the function I ended up using got it from a website but forgot which
site it was still looking for it so I at least have it mentioned in the code
as the original source.

JS code:
function getStuff(getCode){
    $('codeData').options.length = 0;

    var getValue = $(getCode).value;
    new Ajax.Request('../includes/queryfunctions.php',
                     {method:'post',
                         parameters:'groupCode='+getValue,
                         onComplete: function(transport){
                             var response = transport.responseText || "no
response text";
                             if(response != 404){
                                 if(eval(response)) {
                                    var my_options = $A(eval(response));
                                    $A(my_options).each(function(s, index) {
                                      var tmp = $A(s);
                                      var opt =
document.createElement('option');
                                       opt.text = tmp[1];
                                       opt.value = tmp[0];
                                       $('flowerData').options.add(opt);
                                    });
                                }
                            }else{
                                alert('No records found try again
later...');
                            }
                         },
                         onFailure: function(){
                            alert('No records found try again later...');
                         }
                     });

}

PHP Code:

$rxPost = $connObj->cleanVariable($_POST['groupCode']);
if(!empty($rxPost)){
    $sql = "SELECT .... WHERE groupCode = $rxPost";
    $connObj->query($sql);
    if($connObj->num_rows() > 0){

        $tableData = "[";
        $tmpArray = array();
        array_push($tmpArray,"['','']");
        while($rowData = $connObj->query_fetch(0)){
            $f_ID = $rowData['productCode'];
            $f_Name = $rowData['productName'];
            array_push($tmpArray,"['".$f_ID."','".$f_Name."']");
            //$tableData .= "<option value=\"$f_ID\">$f_Name</option>";
        }
        $tableData .= join(',',$tmpArray);
        $tableData .= "]";

        //$tableData .= "</select>";
        echo $tableData;
    }else{
        echo 404;
    }
    exit;
}
//END OF CODES

Thanks for the responses though.
Kind regards

- Jason

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to