국가 선택드롭메뉴를 디비에 전송

매출이 오르면 내리는 수수료! 지금 수수료센터에서 전자결제(PG)수수료 비교견적 신청해 보세요!
국가 선택드롭메뉴를 디비에 전송

QA

국가 선택드롭메뉴를 디비에 전송

본문

주문서 orderform.php 주문서 주소기입란에  국가 선택메뉴를 만들고 있는데요. 이미 회원가입할때 국적선택 mb_country에는 유사한 폼으로 제작은 되었는데  default 로 주문서에는 드롭다운 메뉴에서 회원 가입된 국가로는 나오고 있습니다

그런데 주문넣으면 선택한 국가를 g5_order_table 테이블에 od_country 라는 필드로 보내고 싶은데요 form 태그로 짜서 action post 를 써야할거 같은데 어떻게 치고 해야할지 모르겠네요 기존 주소폼을 어떻게 바꿔야할지 난감하네욥 ㅠㅠ 

1. 회원가입시 국적선택 
​​​​​​

<select name="mb_country" id="reg_mb_country" class="frm_input frm_address select-country">
  <option value="">Select Country</option>
<?php
   $selectedCountry = $member['mb_country']; 
?>
</select>
<script>
  var selectedCountry = "<?php echo $selectedCountry; ?>";
  var countries = ["AFGHANISTAN", "ALBANIA", "ALGERIA", "ANDORRA", "ANGOLA", "ANTIGUA AND BARBUDA"];
for (var i = 0; i < countries.length; i++) {
  var select = document.getElementById("reg_mb_country");
  var option = document.createElement("option");
  option.text = countries[i];
  option.value = countries[i];
  select.add(option);
}

  var select = document.getElementById("reg_mb_country");
  for(var i = 0; i < countries.length; i++) {
    var opt = countries[i];
    var el = document.createElement("option");
    el.textContent = opt;
    el.value = opt;
    // check if this country is the selected country
    if (opt === selectedCountry) {
      el.selected = true;
    }
    
    select.appendChild(el);
  }
</script>
 


2. 주문서  국적선택코드

<select name="mb_country" id="reg_mb_country" class="frm_input frm_address select-country">
    <option value="">Select Country</option>
    <?php 
    $countries = ["AFGHANISTAN", "ALBANIA", "ALGERIA", "ANDORRA", "ANGOLA", "ANTIGUA AND "ZIMBABWE"]; // 나라 목록
 
    foreach($countries as $country) {
        echo '<option value="'.$country.'"'.($country == $member['mb_country'] ? ' selected' : '').'>'.$country.'</option>';
    }
    ?> 
</select>  
<label for="od_country">Country/Region </label>
<br/>
<input type="text" name="od_addr1" value="<?php echo get_text($member['mb_addr1']) ?>" id="od_addr1" required class="frm_input frm_address required" size="60">
<label for="od_addr1">Street address, P.O. box, company name, c/o<strong class="sound_only">required</strong></label>
                    <br/>
.

 

32287339_1696856556.3009.png

이 질문에 댓글 쓰기 :

답변 1

od_addr1이 있는 쪽에 mb_country를 넣으셨으니 

orderformupdate.php 에서 저장하는 부분을 수정하시면 될듯 합니다.


// 주문서에 입력
$sql = " insert {$g5['g5_shop_order_table']}
            set od_id             = '$od_id',
            mb_country             = '$mb_country',
답변을 작성하시기 전에 로그인 해주세요.
전체 61
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT