* 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>
2015-11-02 13:09 · (0)
* 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
2015-11-02 14:21 (edited 2015-11-02 14:31 by Graham ) · (0)
* admin_teGa * Graham The code was written in part? Could write his code placement
2015-11-02 20:27 · (0)
* admin_teGa * Graham Mr. Please reply
2015-11-03 01:08 · (0)
* 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.
2015-11-03 20:10 (edited 2015-11-03 20:13 by Lordeagle ) · (0)
* admin_teGa * Lordeagle Please full codes
2015-11-03 20:52 · (0)
* Lordeagle * admin_teGa Dont get you.
2015-11-03 23:51 · (0)
* Rare Html codes are not supported in window alert, and use ' (apostrophy) in javascript dont use " (quotation mark)
2016-02-23 19:00 · (0)
* AGKLOADED * Lordeagle Where should i put it
2018-09-18 05:52 · (0)

Online: Guests: 1