2014-01-14 2 views
0

텍스트 상자가 있고 드롭 다운, 내 문제는 공급 업체 및 국가 두 드롭 다운 있지만 공급 업체 드롭 다운 유일한 가져가는 국가 드롭 다운. 내가 잘못하고 경우 .ANY 하나가 말해) 데이터베이스에서 데이터를 드롭 다운 표시하고아약스 드롭 다운 값을 전달하는 방법

HTML :

<form name="welcomeDiv1" id="welcomeDiv1"> 

<select name="supplier" id="supplier" style="margin:122px 0 0 939px;background-color:#E8E8E8;width:100px;position: absolute;"> 
    <option value="">Select supplier</option> 
<?php 

$sqlsupplier=mysql_query("SELECT supplier_id FROM supplier"); 


while($row=mysql_fetch_assoc($sqlsupplier)) 

{ 

    echo "<option value='" . $row['supplier_id'] . "'>" . $row['supplier_id'] . "</option>"; 
} 

    ?> 


</select> 


    <select id="country" name="country" style="margin:122px 0 0 511px;background-color:#E8E8E8;width:100px;position: absolute;" > 
     <option value="">Select Country</option> 
     <?php 

      $query = "SELECT DISTINCT country FROM globalnetwork"; 
      $result = mysql_query($query); 
      while($row = mysql_fetch_array($result)){ 
       echo "<option value='" . $row['country'] . "'>" . $row['country'] . "</option>"; 
      } 

     ?> 
    </select> 

</form> 

    <img src="/image/add-new.png" style="margin:116px 0 -5px 2659px;cursor:pointer;position: absolute;" class="billingadddet_button" > 

자바 스크립트

$(function() { 
    $(".billingadddet_button").click(function() { 

    var CPH_GridView1_billingmonthid = $("#CPH_GridView1_billingmonthid").val(); 
    var CPH_GridView1_clientid = $("#CPH_GridView1_clientid").val(); 
    var CPH_GridView1_clientname= $("#CPH_GridView1_clientname").val(); 
    var CPH_GridView1_billingyear= $("#CPH_GridView1_billingyear").val(); 
    var CPH_GridView1_billingmonth = $("#CPH_GridView1_billingmonth").val(); 
    var CPH_GridView1_country = $("#country").val(); 
    var CPH_GridView1_supplier = $("#supplier").val(); 

    var dataString = 'CPH_GridView1_billingmonthid='+ CPH_GridView1_billingmonthid +'&CPH_GridView1_clientid='+CPH_GridView1_clientid+'&CPH_GridView1_clientname='+CPH_GridView1_clientname+'&CPH_GridView1_billingyear='+CPH_GridView1_billingyear+'&CPH_GridView1_billingmonth='+CPH_GridView1_billingmonth+'&CPH_GridView1_country='+CPH_GridView1_country+'&CPH_GridView1_supplier='+CPH_GridView1_supplier; 


    if(CPH_GridView1_clientid=='') 
    { 
    alert("Please Enter Some Text"); 
    } 
    else 
    { 
    $("#flash").show(); 
    $("#flash").fadeIn(400).html; 

    $.ajax({ 
    type: "POST", 
    url: "insertdetailed.php", 
    data: dataString, 
    cache: false, 
    success: function(html){ 
    $("#display").after(html); 

    window.location = '?action=billingdatainputandexportdetailedreport'; 
    $("#flash").hide(); 
    } 
    }); 
    } return false; 
    }); 
    }); 

insertdetailed.php

$billingmonthid = $_POST['CPH_GridView1_billingmonthid']; 
if(isSet($_POST['CPH_GridView1_billingmonthid'])) 

{ 
$billingmonthid = $_POST['CPH_GridView1_billingmonthid']; 
$clientid=$_POST['CPH_GridView1_clientid']; 
$clientname=$_POST['CPH_GridView1_clientname']; 
$billingyear=$_POST['CPH_GridView1_billingyear']; 
$billingmonth=$_POST['CPH_GridView1_billingmonth']; 
$country=$_POST['CPH_GridView1_country']; 
$supplier=$_POST['CPH_GridView1_supplier']; 

$sql_insert="insert into billingdetailedreport(billingmonthid,clientid,clientname,billingyear,billingmonth,supplier,country) values ('$billingmonthid','$clientid','$clientname','$billingyear','$billingmonth','$supplier','$country')"; 
//print "Here"; 
print $sql_insert; 
mysql_query($sql_insert); 

} 

답변

1

) (또한

$("#supplier option:selected").val(); 

나는 $ ("# welcomeDiv1") .serialize를 사용하는 것이 좋습니다 수 있습니다 Suplier

이이

$("#country option:selected").val(); 

같은 시도 아약스 요청에 사용하십시오.

홉 이것은 도움이 될 것입니다.

관련 문제