admin_teGa
Help me, javascript not work
<! DOCTYPE html>
<html>
<head>
<script language="javascript">
function Login(){
var username=document.login.username.value;
username=username.toLowerCase();
var password=document.login.password.value;
password=password.toLowerCase();
if (username=="payung hitam" && password=="trii"){
alert("<img src='img/07.gif' width='' height='' style=''><br/>Yeah!! Jawaban Kamu Benar!");
window.location='lv1win.html';
}
else{
alert("<img src='img/03.gif' width='' height='' style=''/><br/>Ohh!! Jawaban Kamu Salah!");
}
}
</script>
</head>
<body>
<form name="login">
<input type="hidden" name="password" value="trii">
<div class="jwb">
<input name="username" type="text" style="background:#fff;padding:10px;color:#008B8B;border:2px solid #fff;border-radius:5px;font-size:20px"/>
<input style="background:#008B8B;padding:10px;color:#fff;border:2px solid #008B8B;border-radius:5px;font-size:20px" onclick="Login()" type="button" value="cek" />
</div>
</form>
</body>
</html>
Graham
admin_teGa Actually it is working fine
you just cannot "alert" html like that alert just outputs text
add a div with a id as a target and use innerHTML
<div id="abc"></div>
and then instead of alert use
document.getElementById("abc").innerHTML="<img src='img/07.gif' width='' height='' style=''><br/>Yeah!! Jawaban Kamu Benar!";
and
document.getElementById("abc").innerHTML="<img src='img/03.gif' width='' height='' style=''/><br/>Ohh!! Jawaban Kamu Salah!";
or just use text only in the alert
admin_teGa
Graham The code was written in part? Could write his code placement
Lordeagle
admin_teGa Just as Graham has said u cant output html using window alert only the source code will be displayed so use the suggested method above, you can also use
<span style="background:inherit;color:#f00" id="abc"></span> u duplicate itc an use it with the two input field and change their id . Using a function can help as well
function info(msg,id){document.getElementById(id).innerHTML=msg;} u can add it in the if statement thus info("wrong password","password");weong password is the message and id is the targeted id.
Rare
Html codes are not supported in window alert, and use ' (apostrophy) in javascript dont use " (quotation mark)