JavaScript - validar checkbox

 
Vista:
Imágen de perfil de luis eduardo

validar checkbox

Publicado por luis eduardo (1 intervención) el 15/11/2014 19:51:27
estoy creando una pagina pequeña para un trabajo que consta en seleccionar imagenes que son partes de una imagen final, la imagen final la tngo para agregarla pero no se como hacer la combinacion en javascript si m pueden ayudar porfavor es urgente
este es el codigo
y no entiendo como hacer un if en el codigo que me diga que al elegir los checkbox seleccionados me produzca una imagen final


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
<html>
<head>
    <script type="text/javascript">
	function anadir(obj) {
			anadir1(obj);
			if (obj.name =='search_query1'||'search_query2'||'search_query2'){
			anadirImgSQ1();
            anadirImgSQ2();
 
 
			}
 
		}
 
	function anadir1(obj) {
			var radios = document.getElementsByTagName('input');
			var value;
			obj.form.search_query.value = "";
			for (var i = 0; i < radios.length; i++) {
				if (radios[i].type === 'radio' && radios[i].checked) {
				value = radios[i].value;
				obj.form.search_query.value = obj.form.search_query.value + value;
				}
 
			}
		}
	function anadirImgSQ1(){
			var radio = document.getElementsByName('search_query1');
			var cuello = document.getElementById('cuello');
			if (radio[0].checked){
				cuello.src = "../pagina/imagenes/mujer/cuellos/1.png";
			}
			if (radio[1].checked){
				cuello.src = "../pagina/imagenes/mujer/cuellos/2.png";
			}
			if (radio[2].checked){
				cuello.src = "../pagina/imagenes/mujer/cuellos/3.png";
			}
 
 
 
			if (radio[3].checked){
				mangas.src ="../pagina/imagenes/mujer/Mangas/1.png" ;
			}
			if (radio[4].checked){
				mangas.src ="../pagina/imagenes/mujer/Mangas/2.png" ;
			}
			if (radio[5].checked){
				mangas.src ="../pagina/imagenes/mujer/Mangas/3.png" ;
			}
 
 
 
			if (radio[6].checked){
				bolsillo.src ="../pagina/imagenes/mujer/bolsillo/1.png" ;
			}
			if (radio[7].checked){
				bolsillo.src ="../pagina/imagenes/mujer/bolsillo/2.png" ;
			}
			if (radio[8].checked){
				bolsillo.src ="../pagina/imagenes/mujer/bolsillo/3.png" ;
			}
		  }
 
</script>
 
</head>
 
    <div id="search_block_left" class="block exclusive">
        <form name="formulario" method="post" action="{$link->getPageLink('search', true)}" id="searchbox">
            <p class="block_content">
                <label for="search_query_block"></label>
                <input type="hidden" name="orderby" value="position" />
                <input type="hidden" name="controller" value="search" />
                <input type="hidden" name="orderway" value="desc" />
                <!-- Selectores Personal Shoppers -->
          <table width="480" height="139" border="1" >
			<tr>
			<td colspan="3"><img src="../pagina/imagenes/10755014_796052263788437_1225127090_n.jpg" width="100" height="100"></td>
			</tr>
            <tr>
			<td colspan="3"><p>Diseñe su polera escogiendo las siguientes opciones</p></td>
			</tr>
			<tr>
			<td width="157">Escoja un tipo de cuello </td>
			<tr>
            <td><input type="checkbox" name="search_query1" value="c1" onChange="anadir(this)"  align="top"/><img src=                    "../pagina/imagenes/mujer/cuellos/1.png" width="100" height="100 "align="middle" border="1"></td>
            <td width="170"><input type="checkbox" name="search_query1" value="c2 " onChange="anadir(this)"  /> <img src=                    "../pagina/imagenes/mujer/cuellos/2.png" width="100" height="100 "align="middle" border="1"></td>
            <td width="133"><input type="checkbox" name="search_query1" value="c3" onChange="anadir(this)"  /><img src=                    "../pagina/imagenes/mujer/cuellos/3.png" width="100" height="100 "align="middle" border="1"></td>
			</tr>
			<tr>
			<td>Escoja un tipo de mangas</td>
			</tr>
            <tr>
            <td><input type="checkbox" name="search_query1" value="m1" onChange="anadir(this)"align="top"/><img src="../pagina/imagenes/mujer/Mangas/1.png" width="100" height="100 "align="middle" border="1"></td>
            <td><input type= "checkbox" name="search_query1" value="m2 " onChange="anadir(this)" align="top"/><img src="../pagina/imagenes/mujer/Mangas/2.png" width="100" height="100 "align="middle" border="1"></td>
			<td><input type="checkbox" name="search_query1" value="m3 " onChange="anadir(this)" align="top"/><img src="../pagina/imagenes/mujer/Mangas/3.png" width="100" height="100 "align="middle" border="1"></td>
            </tr>
			<tr>
			<td>Escoja un tipo de bolsillo</td>
			</tr>
            <tr>
            <td><input type="checkbox" name="search_query1" value="b1 " onChange="anadir(this)" align="top"/><img src="../pagina/imagenes/mujer/bolsillo/1.png" width="100" height="100 "align="middle" border="1"></td>
            <td><input type="checkbox" name="search_query1" value="b2 " onChange="anadir(this)" align="top"/><img src="../pagina/imagenes/mujer/bolsillo/2.png" width="100" height="100 "align="middle" border="1"></td>
			<td><input type="checkbox" name="search_query1" value="b3 " onChange="anadir(this)" align="top"/><img src="../pagina/imagenes/mujer/bolsillo/3.png" width="100" height="100 "align="middle" border="1"></td>
            </tr>
               <input class="search_query" type="hidden" id="search_query_block" name="search_query" value="" />
           </table>
            </p>
        </form>
    </div>
 <img name="cuello" id="cuello" border="1" width="200" height="200"<img src="../pagina/imagenes/imagenes apk/10749509_796052213788442_1262560052_n.jpg">
 
 <img name="mangas" id="mangas" border="1"width="200" height="200"<img src="../pagina/imagenes/imagenes apk/10749509_796052213788442_1262560052_n.jpg">
 
 <img name="bolsillo" id="bolsillo" border="1"width="200" height="200"<img src="../pagina/imagenes/imagenes apk/10749509_796052213788442_1262560052_n.jpg">
 <img name="imgf" id="imgf" border="1"width="200" height="200"<img src="../pagina/imagenes/imagenes apk/10749509_796052213788442_1262560052_n.jpg">
</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