• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Compare colors

vektra112

Lurker
Hello!

I'm developing simple android app with phonegap in Eclipse and I'm having problem with my code. When correct color is clicked the program should continue and if wrong color is clicked the it resets. Now if I click correct or wrong color the message is always "you lose".

Here is the code:

[HIGH]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<link rel="stylesheet" type="text/css" href="style.css"/>
<script type="text/javascript" src="jquery.js"></script>
</head>
<body>
<div id="info">
<center>
<input type="text" name="boja" id="boja" size="6"/>
<input type="text" name="bodovi" id="bodovi" size="6"/>
<input type="text" name="pogodjeni" id="pogodjeni" size="6"/>
</center>
</div></br>
<center><div id="poruka" style="background-color:white;height:20px;width:200px;color:blue">
</div>
</center>
<br/><center><div id="kutija" style="height:200px;width:160px;">
<div id="prvi" style="background-color:red;height:80px;width:80px;float:left"></div>
<div id="drugi" style="background-color:white;height:80px;width:80px;float:right"></div>
<br/>
<div id="treci" style="background-color:blue;height:80px;width:80px;float:left"></div>
<div id="cetvrti" style="background-color:green;height:80px;width:80px;float:right"></div>
</div>
</center>
<center>
<br/>
</center>
<script type="text/javascript">
var boje=['white','blue','red','green'];
$('#vrijeme').ready(function() {
var odabir = boje[Math.floor(Math.random() * 4)];
$('#boja').css('background-color',odabir);
$('#boja').val('');
$('#bodovi').val('0');
$('#pogodjeni').val('0');
$('#poruka').empty();
});
</script>
<script type="text/javascript">
$(this).click(function() {
var pogodak=$('#pogodjeni').val();
if(pogodak<4) {
var kliknuta_boja=$(this).css('background-color');
var random_boja=$('#boja').css('background-color');
if(kliknuta_boja==random_boja) {
$('#poruka').empty();
$('#poruka').append('continue');
} else {
$('#poruka').empty();
$('#poruka').append('You loose!');
$('#bodovi').val('0');
$('#pogodjeni').val('0');
}
} else {
$('#poruka').empty();
$('#poruka').append('Winner! Winner! Winner!');
}
});
</script>
</body>
</html>


[/HIGH]
 
Back
Top Bottom