여분필드 쪼개서 수정 시 값 가져오는 방법 문의
본문
<?php
if ($w == "u") {
$wr_31x = explode("|",substr($write['wr_31'],1));
}
?>
<table id="table1" cellspacing="0" cellpadding="0">
<tr class="sound_only">
<th>구분</th>
</tr>
<?php
$wr31_cnt = count($wr_31x);
if(!$wr31_cnt){
$wr31_cnt = 1;
}
for ($i = 0; $i < $wr31_cnt; $i++) {
?>
<tr>
<td>
<input type="text" name="wr_31x[]" value="상품명" size=15><input type="text" name="wr_32x[]" size=30><input type="text" name="wr_33x[]" value="상품URL" size=15><input type="text" name="wr_34x[]" size=30><br>
<input type="text" name="wr_35x[]" value="가격" size=15><input type="text" name="wr_36x[]" size=30><input type="text" name="wr_37x[]" value="수량" size=15><input type="text" name="wr_38x[]" size=30><br>
<input type="text" name="wr_39x[]" value="옵션" size=15 ><input type="text" name="wr_40x[]" size=80>
<input type="button" value="삭제" class="tabledel_btn" onclick="ob_adRows.delRow(this)"/>
</td>
</tr>
</div>
<?php } ?>
<input style="float:right; margin:5px 2px" type="button" value="Add Row at end" onclick="ob_adRows.addRow()"/>
<table id="dyntbl1" cellspacing="0" cellpadding="0"></table>
<script>
function adRowsTable(id){
var table = document.getElementById(id);
var me = this;
if(document.getElementById(id)){
var row1 = table.rows[1].outerHTML;
function setIds(){
var tbl_id = document.querySelectorAll('#'+ id +' .tbl_id');
for(var i=0; i<tbl_id.length; i++) tbl_id[i].innerHTML = i+1;
}
me.addRow = function(btn){
btn ? btn.parentNode.parentNode.insertAdjacentHTML('afterend', row1): table.insertAdjacentHTML('beforeend',row1);
setIds();
}
me.delRow = function(btn){
btn.parentNode.parentNode.outerHTML ='';
setIds();
}
}
}
var ob_adRows = new adRowsTable('table1');
</script>
요래 저래 돌아 당기도 찾아보고 하다, 위 내용을 찾게 되었는데, 수정을 할 시 해당 값을 가지고 오는 방법이 있을가요?
!-->답변 2
상단에 여분 필드를 구분자로 쪼개서 가지고 오게하는것까지는 맞게 처리하신거 같은데요
문제는 입력 받아서 처리하실떄 배열로 처리하셨네요?
그리고 입력받아서 처리할 필드가 여러개인데
if ($w == "u") {
$wr_31x = explode("|",substr($write['wr_31'],1));
}
if ($w == "u") {
$wr_31x = explode("|",substr($write['wr_31'],1));
$wr_32x = explode("|",substr($write['wr_32'],1));
$wr_33x = explode("|",substr($write['wr_33'],1));
$wr_34x = explode("|",substr($write['wr_34'],1));
$wr_35x = explode("|",substr($write['wr_35'],1));
$wr_36x = explode("|",substr($write['wr_36'],1));
$wr_37x = explode("|",substr($write['wr_37'],1));
$wr_38x = explode("|",substr($write['wr_38'],1));
}
상단에서 이렇게 처리하신후에
for ($i = 0; $i < $wr31_cnt; $i++) {
?>
<tr>
<td>
<input type="text" name="wr_31x[]" value="<?=$wr_31x[$i]?>" size=15><input type="text" name="wr_32x[]" value="<?=$wr_32x[$i]?>" size=30><input type="text" name="wr_33x[]" value="<?=$wr_33x[$i]?>" size=15><input type="text" name="wr_34x[]" value="<?=$wr_34x[$i]?>" size=30><br>
<input type="text" name="wr_35x[]" value="<?=$wr_35x[$i]?>" size=15><input type="text" name="wr_36x[]" value="<?=$wr_36x[$i]?>" size=30><input type="text" name="wr_37x[]" value="<?=$wr_37x[$i]?>" size=15><input type="text" name="wr_38x[]" value="<?=$wr_38x[$i]?>" size=30><br>
<input type="text" name="wr_39x[]" value="<?=$wr_39x[$i]?>" size=15 ><input type="text" name="wr_40x[]" value="<?=$wr_40x[$i]?>" size=80>
<input type="button" value="삭제" class="tabledel_btn" onclick="ob_adRows.delRow(this)"/>
</td>
</tr>
</div>
<?php } ?>
요렇게 처리해야 맞을꺼 같습니다.
!-->!-->!-->아래 처럼 수정해보세요.
<?php
$wr31_cnt = count($wr_31x);
if(!$wr31_cnt){
$wr31_cnt = 1;
}
for ($i = 0; $i < $wr31_cnt; $i++) {
?>
<tr>
<td>
<input type="text" name="wr_31x[]" value="<?=$wr_31x[$i]?>" size=15><input type="text" name="wr_32x[]" value="<?=$wr_32x[$i]?>" size=30><input type="text" name="wr_33x[]" value="<?=$wr_33x[$i]?>" size=15><input type="text" name="wr_34x[]" value="<?=$wr_34x[$i]?>" size=30><br>
<input type="text" name="wr_35x[]" value="<?=$wr_35x[$i]?>" size=15><input type="text" name="wr_36x[]" value="<?=$wr_36x[$i]?>" size=30><input type="text" name="wr_37x[]" value="<?=$wr_37x[$i]?>" size=15><input type="text" name="wr_38x[]" value="<?=$wr_38x[$i]?>" size=30><br>
<input type="text" name="wr_39x[]" value="<?=$wr_39x[$i]?>" size=15 ><input type="text" name="wr_40x[]" value="<?=$wr_40x[$i]?>" size=80>
<input type="button" value="삭제" class="tabledel_btn" onclick="ob_adRows.delRow(this)"/>
</td>
</tr>
</div>
<?php } ?>
답변을 작성하시기 전에 로그인 해주세요.