데이터 전달방법

데이터 전달방법

QA

데이터 전달방법

답변 2

본문

페이지에서 배송지 목록을 누르면 창이 하나 뜨고 그중에서 선택을 누르면 이름 주소 전화번호등이 넘어오게 만들어져 있는데 이름만 넘어오고 다른 정보는 전달이 안되네요ㅠㅠ 아래는 배송지 목록 소스입니다.

<form name="forderaddress" method="post" action="<?php echo $order_action_url; ?>" autocomplete="off">
<div id="sod_addr" class="new_win">

    <h1 id="win_title">배송지 목록</h1>

    <div class="tbl_head01 tbl_wrap">
        <table>
        <thead>
        <tr>
            <th scope="col">
                <label for="chk_all" class="sound_only">전체선택</label>
                <input type="checkbox" name="chk_all" id="chk_all">
            </th>
            <th scope="col">배송지명</th>
            <th scope="col">기본<br>배송지</th>
            <th scope="col">이름</th>
            <th scope="col">전화번호</th>
            <th scope="col">주소</th>
            <th scope="col">관리</th>
        </tr>
        </thead>
        <tbody>
        <?php
        $sep = chr(30);
        for($i=0; $row=sql_fetch_array($result); $i++) {
            $addr = $row['ad_name'].$sep.$row['ad_tel'].$sep.$row['ad_hp'].$sep.$row['ad_zip1'].$sep.$row['ad_zip2'].$sep.$row['ad_addr1'].$sep.$row['ad_addr2'].$sep.$row['ad_addr3'].$sep.$row['ad_jibeon'].$sep.$row['ad_subject'];
            $addr = get_text($addr);
        ?>
        <tr>
            <td class="td_chk">
                <input type="hidden" name="ad_id[<?php echo $i; ?>]" value="<?php echo $row['ad_id'];?>">
                <label for="chk_<?php echo $i;?>" class="sound_only">배송지선택</label>
                <input type="checkbox" name="chk[]" value="<?php echo $i;?>" id="chk_<?php echo $i;?>">
            </td>
            <td class="td_name">
                <label for="ad_subject<?php echo $i;?>" class="sound_only">배송지명</label>
                <input type="text" name="ad_subject[<?php echo $i; ?>]" id="ad_subject<?php echo $i;?>" class="frm_input" size="12" maxlength="20" value="<?php echo get_text($row['ad_subject']); ?>">
            </td>
            <td class="td_default">
                <label for="ad_default<?php echo $i;?>" class="sound_only">기본배송지</label>
                <input type="radio" name="ad_default" value="<?php echo $row['ad_id'];?>" id="ad_default<?php echo $i;?>" <?php if($row['ad_default']) echo 'checked="checked"';?>>
            </td>
            <td class="td_namesmall"><?php echo get_text($row['ad_name']); ?></td>
            <td class="td_numbig"><?php echo $row['ad_tel']; ?><br><?php echo $row['ad_hp']; ?></td>
            <td><?php echo print_address($row['ad_addr1'], $row['ad_addr2'], $row['ad_addr3'], $row['ad_jibeon']); ?></td>
            <td class="td_mng">
                <input type="hidden" value="<?php echo $addr; ?>">
                <button type="button" class="sel_address">선택</button>
                <a href="<?php echo $_SERVER['SCRIPT_NAME']; ?>?w=d&ad_id=<?php echo $row['ad_id']; ?>" class="del_address">삭제</a>
            </td>
        </tr>
        <?php
        }
        ?>
        </tbody>
        </table>
    </div>
    <div class="win_btn">
        <input type="submit" name="act_button" value="선택수정" class="btn_submit">
        <button type="button" onclick="self.close();">닫기</button>
    </div>
</div>
</form>
<?php echo get_paging($config['cf_write_pages'], $page, $total_page, "{$_SERVER['SCRIPT_NAME']}?$qstr&page="); ?>
<script>

$(function() {
    $(".sel_address").on("click", function() {

        var addr = $(this).siblings("input").val().split(String.fromCharCode(30));

        var f = window.opener.forderform;
        f.od_b_name.value        = addr[0];
        f.od_b_tel.value         = addr1[1];
        f.od_b_hp.value          = addr[2];
        f.od_b_zip.value         = addr[3] + addr[4];
        f.od_b_addr1.value       = addr[5];
        f.od_b_addr2.value       = addr[6];
        f.od_b_addr3.value       = addr[7];
        f.od_b_addr_jibeon.value = addr[8];
        f.ad_subject.value       = addr[9];

        var zip1 = addr[3].replace(/[^0-9]/g, "");
        var zip2 = addr[4].replace(/[^0-9]/g, "");
        


        
        if(zip1 != "" && zip2 != "") {
            var code = String(zip1) + String(zip2);

            if(window.opener.zipcode != code) {
                window.opener.zipcode = code;
                window.opener.calculate_sendcost(code);
            }
        }

        window.close();
    });     
</script>

 

이렇게 되있는데 자신을 연 창의 input의 value값을 addr[]로 바꾸지 않나요?

f.od_b_name.value        = addr[0]; 이름은 정상적으로 넘어오는데 다른건 적용이 안되네요...

window.close();도 적용이 안돼요...페이지 소스는 간략하게

<tr>
                            <th scope="row">배송지선택</th>
                            <td>
                                <?php echo $addr_list; ?>
                            </td>
                        </tr>
                        <?php if($is_member) { ?>
                        <tr>
                            <th scope="row"><label for="ad_subject">배송지명</label></th>
                            <td>
                                <input type="text" name="ad_subject" id="ad_subject" class="js_input input_sm required wp30" maxlength="20">
                                <input type="checkbox" name="ad_default" id="ad_default" value="1">
                                <label for="ad_default">기본배송지로 설정</label>
                            </td>
                        </tr>
                        <?php } ?>

                        <tr>
                            <th scope="row"><label for="od_b_name">이름<strong class="sound_only"> 필수</strong></label></th>
                            <td>
                                <input type="text" name="od_b_name" id="od_b_name" required class="js_input input_sm required wp30" maxlength="20">
                            </td>
                        </tr>

                        <!--tr>
                            <th scope="row"><label for="od_b_tel">전화번호<strong class="sound_only"> 필수</strong></label></th>
                            <td>
                                <input type="text" name="od_b_tel" id="od_b_tel" class="js_input input_sm wp30" maxlength="20">
                            </td>
                        </tr-->

                        <tr>
                            <th scope="row"><label for="od_b_hp">연락처</label></th>
                            <td>
                                <input type="text" name="od_b_hp" id="od_b_hp" required class="js_input input_sm required wp30" maxlength="20">
                            </td>
                        </tr>

                        <tr>
                            <th scope="row">주소</th>
                            <td id="sod_frm_addr">
                                <label for="od_b_zip" class="sound_only">우편번호<strong class="sound_only"> 필수</strong></label>
                                <input type="text" name="od_b_zip" id="od_b_zip" required class="js_input input_sm required" size="6" maxlength="6">
                                <button type="button" class="js_btn btn_sm" onclick="win_zip('forderform', 'od_b_zip', 'od_b_addr1', 'od_b_addr2', 'od_b_addr3', 'od_b_addr_jibeon');">주소 검색</button>
                                <p class="mt_5"><input type="text" name="od_b_addr1" id="od_b_addr1" required class="js_input input_sm frm_address required wp60" size="60" placeholder="기본주소"></p>
                                <p class="mt_5"><input type="text" name="od_b_addr2" id="od_b_addr2" class="js_input input_sm frm_address wp60" size="60" placeholder="상세주소"></p>
                                <p class="mt_5"><input type="hidden" name="od_b_addr3" id="od_b_addr3" readonly class="js_input input_sm frm_address wp60" size="60" placeholder="참고항목"></p>
                                <input type="hidden" name="od_b_addr_jibeon" value="">
                            </td>
                        </tr>

 

 

 

 

$("input[name=ad_sel_addr]").on("click", function() {
        var addr = $(this).val().split(String.fromCharCode(30));

        if (addr[0] == "same") {
            gumae2baesong();
        } else {
            if(addr[0] == "new") {
                for(i=0; i<10; i++) {
                    addr[i] = "";
                }
            }

            var f = document.forderform;
            f.od_b_name.value        = addr[0];
            //f.od_b_tel.value         = addr[1];
            f.od_b_hp.value          = addr[2];
            f.od_b_zip.value         = addr[3] + addr[4];
            f.od_b_addr1.value       = addr[5];
            f.od_b_addr2.value       = addr[6];
            f.od_b_addr3.value       = addr[7];
            f.od_b_addr_jibeon.value = addr[8];
            f.ad_subject.value       = addr[9];

            var zip1 = addr[3].replace(/[^0-9]/g, "");
            var zip2 = addr[4].replace(/[^0-9]/g, "");

            var code = String(zip1) + String(zip2);

            if(zipcode != code) {
                calculate_sendcost(code);
            }
        }
    });

 

이정도로 되있습니다ㅠㅠ

이 질문에 댓글 쓰기 :

답변 2

            $addr = $row['ad_name'].$sep.$row['ad_tel'].$sep.$row['ad_hp'].$sep.$row['ad_zip1'].$sep.$row['ad_zip2'].$sep.$row['ad_addr1'].$sep.$row['ad_addr2'].$sep.$row['ad_addr3'].$sep.$row['ad_jibeon'].$sep.$row['ad_subject'];
            $addr = get_text($addr);

chr(30)이 get_text()후에도 살아 남는지?모르겠지만

이렇게 문자열을 합치지 말고

별도의 <input으로 처리하시는 게 확실하지 않을까요?

답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
  • 질문이 없습니다.
전체 0
© SIRSOFT
현재 페이지 제일 처음으로