PDA

Просмотр полной версии : Value


LeonW
14.10.2005, 15:08
Привет всем! кто нибудь понимает в javascripte?
есть код готовый - только как сделать что бы надпись в числе2 не менялась,
только значение?????????

<html><head><title>neznau</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">

<script language="JavaScript">
function calc (form){

var res = parseInt(form.chislo1.value) + parseInt(form.chislo2.value);
form.result.value = res;
}

function reName (form){
var num = new Array();

switch (form.chislo1.value){
case '0':
num[1] = 0;
num[2] = 7;
num[3] = 10;
num[4] = 100;
break;
case '2':
num[1] = 42;
num[2] = 80;
num[3] = 120;
num[4] = 110;
break;
case '3':
num[1] = 83;
num[2] = 160;
num[3] = 240;
num[4] = 2500;
break;
}

for (var i = 1; i<=4; i++){
var Line = document.getElementById ("line"+i);
Line.setAttribute("value", num[i]);
Line.firstChild.nodeValue = num[i];
}
}
</script>

</head>
<body bgColor="#83A7C5"><body background="fan.jpg">

<script language="JavaScript">
function maxlength_lang(form){
var maxlength=101;
str=form.message.value;
dlina=str.length;
if(dlina>maxlength)form.message.value=str.substring(0,maxle ngth);
form.lang.value=(maxlength-dlina);}
required = new Array("mailto", "mailfrom", "subject", "message");
required_show = new Array("Кому", "От кого", "Тема", "Сообщение");
function SendForm () {
var i, j;
for(j=0; j<required.length; j++) {
for (i=0; i<document.forms[0].length; i++) {
if (document.forms[0].elements[i].name == required[j] && document.forms[0].elements[i].value == "" ) {
alert('Вы не заполнили форму "' + required_show[j] + '"');
document.forms[0].elements[i].focus();
return false;
}
}
}
return true;
}
</script>
<center>


<form name="sender" method="post" action="email/regist.php" onsubmit="return SendForm();">

<table cellSpacing=1 cellPadding=0 width="390" BGCOLOR="#DEE3E7" align="center" border=1>
<tr>
<td bgcolor=#DEE3E7 width="100%" align="right"><b>

число1: <select name="chislo1" onchange="reName(document.sender)" onclick="calc (form)">
<option value="0" >1 rejim</option>
<option value="2">2 rekim</option>
<option value="3">3 rejim</option>
</select><br />

чисто2: <select name="chislo2" id="ch2" onclick="calc (form)">
<option id="line1" value="1">0 sekunt</option>
<option id="line2" value="2">7 sekund</option>
<option id="line3" value="3">10 sekund</option>
<option id="line4" value="4">100 sekund</option>
</select><br />


</b></td>
<td bgcolor=#DEE3E7 align="right"></td>
</tr>
</table>
<table cellSpacing=1 cellPadding=0 width="390" height=15% BGCOLOR="#DEE3E7" align="center" border=1>
<tr>
<td bgcolor=#DEE3E7 width="100%" align="center"><b>text maksimo <input type="text" name="lang" size="2" value="101"> simvolov</b><br>
<textarea name=message rows="10" cols="43" onChange="maxlength_lang(document.sender)" onKeyUp="maxlength_lang(document.sender)" onKeyDown="maxlength_lang(document.sender)" onClick="maxlength_lang(document.sender)" onKeyPress="maxlength_lang(document.sender)"></textarea>
<br><br><input type=submit value="> > > > > >"><br><br>

<input type="text" name="result" /></br />


</td>
</tr>
</table>
</form>
</center>


посибо Leon :)