<pre class="line-numbers"><code class="language-php"> function get_member_opt_view($fild, $mb_id, $mb_hp) { global $g5; $sql = "select * from g5_member where mb_level > '2' and mb_level < '5'"; $result = sql_query($sql); for ($i=0; $row=sql_fetch_array($result); $i++) { $str .= "<option value='$row[mb_id]'"; if ($row[mb_id] == $fild or $row[mb_id] == $mb_id) $str .= " selected"; $str .= ">{$row[mb_1]}- {$row[mb_name]} / {$row[mb_3]} / {$row[mb_4]}</option>"; } return $str; } </code></pre> <pre class="line-numbers"><code class="language-markup"> <select id="target_mb" name="target_mb" onchange="target_mb_select();"> <option value="">선택</option> <?php echo get_member_opt_view($fild, $mb_id, $mb_hp) ?> </select> <input type="hidden" name="ca_name" id="mb_id" value=""> <input type="text" name="mb_hp" id="mb_hp" value="" placeholder="담당자 선택하세요" disabled="disabled" style="width:180px;"> </code></pre> //ajax_log.php 파일 <pre class="line-numbers"> <code class="language-php"> <?php $sql = "select * from g5_member where mb_id = '$_GET[mode]'"; $result = sql_query($sql); $row=sql_fetch_array($result); ?> <?=$row['mb_id'];?>|<?=$row['mb_hp'];?>|<?=$row['mb_name'];?> </code> </pre> <pre class="line-numbers"><code class="language-javascript"> <script> function target_mb_select() { if($("#target_mb").val()=='') { writeform_reset(); } else { $.ajax({ url: './ajax_log.php', type: "GET", data: "mode="+$("#target_mb").val(), datatype: "html", success: function(data){ var tmp=data.split('|'); $("#mb_id").val(tmp[0]); $("#mb_hp").val(tmp[1]); }, error: function(){ alert("데이터를 가져오는데 실패했습니다."); } }); } } </script> </code></pre>