내 문제는 여기에 함수 (데이터) 부분에서 오류가 발생하고 이유를 모르겠다 - dreamweaver에서 오류가 발생합니다. 단지 코드에서 오류를 말하는 빨간색 표시를 보여자바 스크립트 코드 오류 - 함수 (데이터) 오류 및 이유를 모르겠 음
<script language="javascript" type="text/javascript">
$("#dropdown").on('change', function() {//when you select something from the dropdown function run and will switch the data
$.post("backgroundScript.php", {
uid: $(this).val()
} function(data) { // right here is the error im getting
$("#first").val(data.first);
$("#last").val(data.last);
// etc.;
}, 'json'
);
});
</script>
내가 뭘하려고 오전
try {
# MySQL with PDO_MYSQL
$DBH = new PDO("mysql:host=$hostname;dbname=$database", $username, $password);
$DBH->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
//$DBH->prepare('SELECT first FROM contacts');
}
catch(PDOException $e) {
echo "I'm sorry, I'm afraid I can't do that.";
file_put_contents('PDOErrors.txt', $e->getMessage(), FILE_APPEND);
}
//get query
$FNresult=$DBH->query('SELECT first FROM contacts');
//set fetch mode
$FNresult->setFetchMode(PDO::FETCH_ASSOC);
$dropdown = "<select name='contacts' id='contacts' >";
while($row =$FNresult->fetch()) {
$dropdown .= "\r\n<option value='{$row['first']}'>{$row['first']}</option>";
// echo getLN();
}
$dropdown .= "\r\n</select>";
echo $dropdown;
//}
/*
// Get last name
function getLN(){
$query = "SELECT last FROM contacts";
$LNresult=mysql_query($query);
$last;
while($row = mysql_fetch_assoc($LNresult)) {
$last = "{$row['last']}";
}
echo $last;
}//end getLN
*/
$DBH = null;
?>
<!-- javascript on client-side -->
<script language="javascript" type="text/javascript">
$("#dropdown").on('change', function() {//when you select something from the dropdown function run and will switch the data
$.post("backgroundScript.php", {
uid: $(this).val()
} function(data) {
$("#first").val(data.first);
$("#last").val(data.last);
// etc.;
}, 'json'
);
});
</script>
<script language="javascript" type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js">
//$("#[id]");
</script>
<form action="insert.php" method="post">
First Name: <input type="text" id="first" name="first"><br>
Last Name: <input type="text" id="last"><br>
Phone: <input type="text" id="phone"><br>
Mobile: <input type="text" id="mobile"><br>
Fax: <input type="text" id="fax"><br>
E-mail: <input type="text" id="email"><br>
Web: <input type="text" id="web"><br>
<input type="Submit">
</form>
이 필요한 게 알려줘 내 코드를 heres 나머지 DB에서 형태의 autofil을 만드는 것입니다 그 외. 그리고 나는 그것을 정말로 감사 할 것이다!
이것은 자바가 아니라 자바 스크립트입니다. 이 문제를 해결하거나 사람들이 혼란 스러울 것입니다. – DMor
'language = "javascript"'- 비추천 속성입니다. –
원래 코드에 함수 (데이터) {} 앞에 쉼표 (,)를 추가하는 것을 잊지 않았습니까? – xdevel