JavaScript - me pueden decir como decir que un input ya tiene algo escrito con un if?

 
Vista:
sin imagen de perfil

me pueden decir como decir que un input ya tiene algo escrito con un if?

Publicado por anonymous (50 intervenciones) el 31/05/2016 06:34:05
el caso es que tengo un programa que dirá una respuesta con los datos que se tienen (que se pusieron) y dará la respuesta según los datos que se tienen:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<!DOCTYPE html>
<html><head>
<style type="text/css">
table {border-collapse:collapse;  border-spacing:0px; border:0px;}
td{border-spacing:0px; border:0px;}
input[type=number]::-webkit-inner-spin-button {-webkit-appearance: none;margin: 0;}
input[type=number] {-moz-appearance:textfield;}
hr {border-width: 1px;border-style: dotted;border-color: white;}
select {width: 60%;font-size:18px;height: 30px;padding:0px;margin: 0px;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;-webkit-box-shadow: 0 0px 0 #ccc, 0 0px #fff inset;-moz-box-shadow: 0 0px 0 #ccc, 0 0px #fff inset;box-shadow: 0 0px 0 #ccc, 0 0px #fff inset;background:linear-gradient(#342E21,#483F2E);color:rgba(0,0,0,1.00);border:none;display: inline-block;cursor:pointer;}
.calculapitagoras{border-radius:12px; background:rgba(58,58,60,1.00);}
.txtr{width: 90%;font-size:18px;height: 30px;padding:0px;margin: 0px;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;-webkit-box-shadow: 0 0px 0 #ccc, 0 0px #fff inset;-moz-box-shadow: 0 0px 0 #ccc, 0 0px #fff inset;box-shadow: 0 0px 0 #ccc, 0 0px #fff inset;background:linear-gradient(#342E21,#483F2E);color:rgba(0,0,0,1.00);border:none;display: inline-block;}
.button{ cursor:pointer;border-radius:5px; height:30px; width:90px; background-color:#11B547; border-color:rgba(0,0,0,0.00)}
.button:hover{background-color: #11A536}
@media screen and (min-width : 0px ) and (max-width : 450px){
select{ width:55%;}
.txtr{width:65%;}}
@media screen and (min-width : 0px ) and (max-width : 300px){
select{ width:60%;}
.txtr{width:75%;}}
</style>
<link href="comenzando.netau.net/estilo.css" rel="stylesheet" type="text/css"/>
<title>Teorema de pitagoras</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<!--  Chrome, Firefox OS y Opera  -->
 <meta name="theme-color" content="#2CBBDF"/>
 <!--  Windows Phone  -->
 <meta name="msapplication-navbutton-color" content="#2CBBDF"/>
 <!--  iOS Safari  -->
<meta name="apple-mobile-web-app-capable" content="#2CBBDF"/>
<meta name="apple-mobile-web-app-status-bar-style" content="#2CBBDF"/>
<link rel="shortcut icon" href="ico.png"/>
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"/>
<script type="text/javascript" language="javascript">
function angdef() {
	 var y = document.getElementById("select").options;
     var x = document.getElementById("select").selectedIndex;
   	 switch (y[x].index){
	 case 0:
	 document.calc.C.disabled=true;
	 document.calc.C.value="90";
	 break;
	 case 1:
	 document.calc.C.disabled=false;
	 document.calc.C.value="";
	 break;
	}}
function limpiar(){
   var y = document.getElementById("select").options;
   var x = document.getElementById("select").selectedIndex;
   	switch (y[x].index){
	case 0:
	document.calc.A.value="";
	document.calc.B.value="";
	document.calc.ca.value="";
	document.calc.cb.value="";
	document.calc.cc.value="";
	document.calc.perimetro.value="";
	document.calc.area.value="";
	break;
	case 1:
    document.calc.A.value="";
	document.calc.B.value="";
    document.calc.C.value="";
	document.calc.ca.value="";
	document.calc.cb.value="";
	document.calc.cc.value="";
	document.calc.perimetro.value="";
	document.calc.area.value="";
	break;
	}}
function calcular(){
    var y = document.getElementById("select").options;
    var x = document.getElementById("select").selectedIndex;
	var A = document.calc.A.value;
	var B = document.calc.B.value;
    var C = document.calc.C.value;
	var ca= document.calc.ca.value;
	var cb= document.calc.cb.value;
	var cc= document.calc.cc.value;
	var perim=document.calc.perimetro.value;
	var area=document.calc.area.value;
   	switch (y[x].index){
	case 0:
	break;
    case 1:
	break;
	}}
</script>
</head>
<body onLoad="angdef()">
<div id="titulopag"><a itemprop="url" class="enlace3 titulopag" href="inicio" target="_blank"></a></div><a href="inicio"><div class="inicio" title="Inicio">Incio</div></a><a href="Contenido"><div class="contenido" title="Contenido">Contenido</div></a><a href="Acerca_de"><div class="acercade" title="Acerca de">Acerca de</div></a>
<div class="panelizq">
  <div class="investigacion">
  <h1 class="titulo">
  <span style="color: #FF00FF">!</span><span style="color: #FF3300">Sa</span><span style="color: #CCFF00">bi</span><span style="color: #2CA3E5">as</span>
  <span style="color:#42D93B">que</span><span style="color: #FF0000">?</span>
  </h1>
     • los angulos son en mayuscula (a mi me dijeron asi) para no confundir con los lados.
</div></div>
<div class="paneldere">
<ul><li>
</li></ul>
</div>
<p></p>
<div class="informacion">
  <div class="investigacion">
    <h1>Calculadora de triangulos</h1>
    <form name="calc" class="calculapitagoras">
    <div class="investigacion">
    <br>
    <h2>Calculadora Triangulos</h2>
     <hr>
 <table width="100%">
  <tbody>
    <tr>
<td>¿Que tipo de triangulo es?<br>
<select id="select" onChange="angdef();">
 <option>Rectangulo</option>
 <option>Obicuangulo</option>
 </select>
</td>
<td width="50%">¿a cuanto desr redondear?
<select id="re2nd" onChange="redondear();">
 <option>2 decimales</option>
 <option>3 decimales</option>
 <option>4 decimales</option>
 <option>5 decimales</option>
 <option>No redondear</option>
</select>
</td>
</tr>
  </tbody>
</table>
 <table width="100%">
  <tbody>
    <tr>
      <td width="50%">Cateto a:<br>
<input class="txtr" type="number" name="ca" autocomplete="off">
 <br>
 <br>Cateto b:<br>
 <input class="txtr" type="number"  name="cb" autocomplete="off">
<br>
<br>Hipotenusa c:<br>
 <input class="txtr" type="number" name="cc" autocomplete="off">
 <br>
<br>Area:<br>
 <input class="txtr" type="number" name="area" autocomplete="off">
 </td>
 <br><td width="50%">Angulo A:<br>
<input class="txtr" type="number" name="A" autocomplete="off">
<br><br>Angulo B:<br>
<input class="txtr" type="number"  name="B" autocomplete="off">
<br><br>Angulo C:<br>
<input class="txtr" type="number" name="C" autocomplete="off">
<br><br>Perimetro:<br>
<input class="txtr" type="number" name="perimetro" autocomplete="off">
</td>
</tr>
</tbody>
</table>
<hr>
<br>
<input type="button" class="button" value="Calcular" onClick="calcular()">
<input type="button" class="button" value="Limpiar" onClick="limpiar()">
<hr>
<label id="procedimiento"></label>
</div>
<br>
</form>
</div>
<br>
</div>
<a href="#" class="scrolltop" style="display: block;"><img src="flecha-top.png" width="50" height="50" alt=""/></a>
<div class="abajo">
<span class="panelbuttom">Fecha de edicion: 6 de Mayo del 2016</span>
<span class="panelbuttomc">Editor: Humberto Molina Lopez</span>
</div>
</body>
</html>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder