Определен текст в input поле?

rotator

Registered
Значи имам ето този код
<!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>
<meta http-equiv="content-type" content="text/html; charset=windows-1251" />
<style type="text/css">
.button {
color: #FFFFFF;
background: #000000;
border: 1px Red Solid;
font-size: 50px;
}
</style>
<script language="JavaScript">
function get_random()
{
var ranNum= Math.floor(Math.random()*5);
return ranNum;
}

function getaQuote()
{
var whichQuote=get_random();

var quote=new Array(5)
quote[0]="Победителят е: User1";
quote[1]="Победителят е: User2";
quote[2]="Победителят е: User3";
quote[3]="Победителят е: User4";
quote[4]="Победителят е: User5";

alert(quote[whichQuote]);
}
</script>
</head>
<body>
<center>
<form>
<input type="button" value="Изтегли Печелившия" onClick="getaQuote()" class="button" />
</form>
</center>
</body>
</html>

Като натисна бутона текста ми излиза като alert. Как ще стане това да излиза в input поле под бутона? +1
 
вместо:
Код:
alert(quote[whichQuote]);
слагаш:
Код:
var bla=document.getElementById('izliza');
bla.value=quote[whichQuote];
и след онзи input слагаш:
Код:
<input type="text" id="izliza">
Не съм го пробвал, но би трябвало да стане.
 
Код:
<!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>
<meta http-equiv="content-type" content="text/html; charset=windows-1251" />
<style type="text/css">
.button {
color: #FFFFFF;
background: #000000;
border: 1px Red Solid;
font-size: 50px;
}
#result {
	width:500px;
	height:50px;
	border:solid 1px red;
	font-size:24px;
	color:#000;
	text-align:center;
}
</style>
<script language="JavaScript">
function get_random()
{
var ranNum= Math.floor(Math.random()*5); 
return ranNum;
}

function getaQuote()
{
var whichQuote=get_random();

var quote=new Array(5) 
quote[0]="Победителят е: User1";
quote[1]="Победителят е: User2";
quote[2]="Победителят е: User3";
quote[3]="Победителят е: User4";
quote[4]="Победителят е: User5";
document.getElementById('result').value= quote[whichQuote];
}
</script>
</head>
<body>
<center>
<form>
<input type="button" value="Изтегли Печелившия" onClick="getaQuote()" class="button" /><br />
<input type="text" name="result" id="result" />
</form>
</center>
</body>
</html>
 
Вие дадохте една точка за support на emagi .
Натиснете тук за да се върнете в темата.
 

Back
Горе