JQuery --> php 변수 넘기기 도와 주세요
본문
1 ========================================================
<?php
add_javascript('<script src="'.$board_skin_url.'/js/doc.js"></script>');
add_stylesheet('<link rel="stylesheet" href="'.$board_skin_url.'/style.css">', 0);
?>
<script>
var cfg = <?php echo json_encode($cfg); ?>;
console.log(cfg);
function frmSubmit() {
var memo = $("#memo").val();
memo = memo.replace(/ /gi, "");
cfg['memo'] = $("#memo").val();
cfg['wr_100'] = $("#wr_100").val();
app_me(cfg);
}
</script>
<select id="wr_100" name="wr_100" class="wr_100" >
<option value="">=선택=</option>
<option value="승인완료">승인완료</option>
<option value="결재진행중">결재진행중</option>
<option value="수정후 상신요망">수정후 상신요망</option>
</select>
<textarea name="memo" id="memo" class="memo required" rows="10" required><?php echo $rs['mb_content']; ?></textarea>
<button type="button" name="save" id="save" onclick="frmSubmit();">저장</button>
2. doc.js ==========================================
function app_me(cfg) {
$.ajax({
url : cfg.board_skin_url+"/_approval_update.php",
type : "POST",
data : {
"bo_table" : cfg.bo_table,
"wr_id" : cfg.wr_id,
"seq" : cfg.z,
"current" : cfg.current,
},
dataType : "json",
async : false,
cache : false,
success : function(data){
parent.rumiPopup.close();
}
});
}
3. approval_update.php===========================================
<?php
$sql = "update
{$write_table}
set
wr_100 = '{$wr_100}', // wr_100 는 값이 안넘어 옵니다
meno ='{$memo}' //memo 는 값 넘어 오는데
where
wr_id = '{$wr_id}' ";
sql_query($sql, true);
?>
답변 3
doc.js
function app_me(cfg) {
~
data : {
"bo_table" : cfg.bo_table,
"wr_id" : cfg.wr_id,
"seq" : cfg.z,
"current" : cfg.current,
~
=>
data : {
"bo_table" : cfg.bo_table,
"wr_id" : cfg.wr_id,
"seq" : cfg.z,
"current" : cfg.current,
"wr_100" : cfg.wr_100,
"memo" : cfg.memo,
cfg['wr_100'] = $("#wr_100").val();을
cfg['wr_100'] = $("#wr_100 option:selected").val();
로해보세요.
cfg['memo'] = $("#memo").val();
cfg['wr_100'] = $("#wr_100").val(); 를
이렇게 바꾸면 wr_100 값이 메모에 등록은 됩니다.. 값은 넘어 옵니다..
cfg['wr_100'] = $("#memo").val();
cfg['memo'] = $("#wr_100").val();