JavaScript - Ventanas Modales

 
Vista:
Imágen de perfil de Julian

Ventanas Modales

Publicado por Julian (2 intervenciones) el 24/10/2017 14:35:06
Buenos días

Lo que pasa es que abro las ventanas del primer formulario y me funciona perfectamente pero cuando abro los links del segundo formulario me cierra por completo el div y me daña el registro, Además de esto deseo que cuando elija un dato de la ventana emergente me lo muestre en la ventana padre alguien me podría colaborar con eso soy súper nuevo y no tengo conocimiento en Jquery

Mi código es así:

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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.Connection"%>
<%@page import="javax.swing.JOptionPane"%>
<!DOCTYPE html>
 <html>
 <head>
<style>
body {font-family: "Lato", sans-serif;}
 
h1.title{
   text-align: center;
}
 
/* Estilo de la tabla */
 
div.tab {
    overflow: hidden;
    border: 5px solid #ccc;
    background-color: #f1f1f1;
    align-items: center;
    margin-right: 40%;
    margin-left: 30%;
}
 
/* Estilo de los botones en la tabla*/
 
div.tab button {
    background-color: inherit;
    float: left;
    border: none;
    outline: none;
    cursor: pointer;
    padding: 14px 16px;
    transition: 0.3s;
    font-size: 17px;
}
 
/* Estilos con los botones : hover */
 
div.tab button:hover {
    background-color: #ddd;
}
 
/* Estilo de los botones seleccionados */
 
div.tab button.active {
    background-color: cyan;
}
 
/* Estilo  de la tabla que contiene */
 
.tabcontent {
    display: none;
    padding: 6px 12px;
    border: 5px solid #ccc;
    border-top: none;
    margin-right: 20%;
    margin-left: 30%;
}
 
</style>
 
 <script>
 function openCity(evt, cityName) {
    var i, tabcontent, tablinks;
    tabcontent = document.getElementsByClassName("tabcontent");
    for (i = 0; i < tabcontent.length; i++) {
        tabcontent[i].style.display = "none";
    }
    tablinks = document.getElementsByClassName("tablinks");
    for (i = 0; i < tablinks.length; i++) {
        tablinks[i].className = tablinks[i].className.replace(" active", "");
    }
    document.getElementById(cityName).style.display = "block";
    evt.currentTarget.className += " active";
}
 </script>
 
 <script type="text/javascript">
    function abrir(url) {
    window.open(url,"Productos","with=10");
         }
 </script>
 
 </head>
 
 <body>
 
 <h1 class="title">Patrick and Sants</h1>
 
<div class="tab">
  <button class="tablinks" onclick="openCity(event, 'Informacion')">Información Básica</button>
  <button class="tablinks" onclick="openCity(event, 'Impuestos')">Impuestos</button>
 
</div>
 
 <div id="Informacion" class="tabcontent">
 <form action="" method="POST">
        <table>
 
        <tr>
        <td>Código de la empresa :&nbsp;&nbsp;</td><td> <input type="text" id="codigo" name="codigo" minlength="2" title="Ejemplo: A2"  required=""/></td>
        <td><input type="submit" name="" value="" onclick="abrir('CodigosEmpresa.jsp')"></td>
        </tr>
 
        <tr>
        <td>Nit : &nbsp;&nbsp;</td><td><input type="text" name="nit" minlength="10" pattern="[0-9-]*"  title="Ejemplo: 123456789-0"  required=""/></td>
        <td><input type="submit" name="" value="" onclick="abrir('NitEmpresa.jsp')"></td>
        </tr>
 
        <tr>
        <td>Nombre : &nbsp;&nbsp;</td><td><input type="text" name="nombre" minlength="4" title="Ejemplo : Ventas " autocomplete="on" required=""/></td>
        <td><input type="submit" name="" value="" onclick="abrir('NombresEmpresa.jsp')"></td>
        </tr>
 
        <tr>
        <td>Dirección : &nbsp;&nbsp;</td><td><input type="text" name="direccion" minlength="15" title="Ejemplo Calle 00 A N 00 B 00" required=""/></td>
        <td><input type="submit" name="" value="" onclick="abrir('DireccionEmpresa.jsp')"></td>
        </tr>
 
        <tr>
        <td>Teléfono :&nbsp;&nbsp;</td><td><input type="text" name="telefono" minlength="7" maxlength="11"  pattern="[0-9]*" title=" Ejemplo: 0980987" required=""/> </td>
        <td><input type="submit" name="" value="" onclick="abrir('TelefonosEmpresa.jsp')"></td>
        </tr>
 
        <tr>
        <td>Correo Electrónico :&nbsp;&nbsp;</td><td><input type="email" name="correo" title="Ejemplo: ejemplo@hotmail.com" required=""/></td>
        <td><input type="submit" name="" value="" onclick="abrir('CorreosEmpresa.jsp')"></td>
        </tr>
 
        <tr>
        <td>Representante Legal :&nbsp;&nbsp;</td><td><input type="text" name="representante" minlength="4" pattern="[a-zA-Z ]*" title="Ejemplo: Juan" required=""/></td>
        <td><input type="submit" name="" value="" onclick="abrir('RepresentanteLegalEmpresa.jsp')"></td>
        </tr>
 
        <tr>
        <td><input type="submit" name="siguiente" value="Siguiente" /></td>
        </tr>
 
        </table>
        </form>
 
   </div>
 
   <div id="Impuestos" class="tabcontent">
   <form action="" method="POST">
 
   <table>
 
   <tr>
   <td>Impuesto de renta :&nbsp;&nbsp;</td><td><input type="number" step="0.1" name="impuestorenta"/></td>
   <td><input type="submit" name="" value="" onclick="abrir('Impuesto_RentaEmpresa.jsp')"></td>
   </tr>
 
   <tr>
   <td>Iva :&nbsp;&nbsp;</td><td><input type="number" step="0.1" name="iva"/></td>
   <td><input type="submit" name="" value="" onclick="abrir('IvaEmpresa.jsp')"></td>
   </tr>
 
   <tr>
   <td>Ica :&nbsp;&nbsp;</td><td><input type="number" step="0.1" name="ica" /></td>
   <td><input type="submit" name="" value="" onclick="abrir('IcaEmpresa.jsp')"></td>
   </tr>
 
   <tr>
   <td>Retención en la fuente :&nbsp;&nbsp;</td><td><input type="number" step="0.1" name="retefuente" /> </td>
   <td><input type="submit" name="" value="" onclick="abrir('RetefuenteEmpresa.jsp')"></td>
   </tr>
 
   <tr>
   <td>Gravamen a los movimientos financiero :&nbsp;&nbsp;</td><td><input type="number" step="0.1" name="gravamenmovimientosfinancieros"/></td>
   <td><input type="submit" name="" value="" onclick="abrir('Gravamen_A_Los_Impuestos_FinancierosEmpresa.jsp')"></td>
   </tr>
 
   <tr>
   <td>Impuesto al patrimonio:&nbsp;&nbsp;</td><td><input type="number" step="0.1" name="impuestopatrimonio"/></td>
   <td><input type="submit" name="" value="" onclick="abrir('Impuesto_PatrimonioEmpresa.jsp')"></td>
   </tr>
 
   <tr>
   <td> <input type="submit" value="Guardar" name="guardar"/> </td>
   </tr>
 
   </table>
 
  </form>
 
<%
 
Connection cnn = null;
PreparedStatement ps = null;
 
if (request.getParameter("guardar")!= null){
    try{
        Class.forName("com.mysql.jdbc.Driver");
        cnn = DriverManager.getConnection("jdbc:mysql://localhost/patricandsants","root","");
 
        try {
	        ps = (PreparedStatement)cnn.prepareStatement("INSERT INTO empresas(codigo,nit,nombre,direccion,telefono,"
	                + "correo_electronico,representante_legal,"
	                + "impuesto_renta,iva,ica,retencion_en_la_fuente,gravamen_a_los_movimientos_financieros,"
	                + "impuesto_al_patrimonio) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)");
 
	        ps.setString(1,request.getParameter("codigo"));
	        ps.setString(2,request.getParameter("nit"));
	        ps.setString(3,request.getParameter("nombre"));
	        ps.setString(4,request.getParameter("direccion"));
	        ps.setString(5,request.getParameter("telefono"));
	        ps.setString(6,request.getParameter("correo"));
	        ps.setString(7,request.getParameter("representante"));
 
	        //impuestos
 
	        ps.setString(8,request.getParameter("impuestorenta"));
	        ps.setString(9,request.getParameter("iva"));
	        ps.setString(10,request.getParameter("ica"));
	        ps.setString(11,request.getParameter("retefuente"));
	        ps.setString(12,request.getParameter("gravamenmovimientosfinancieros"));
	        ps.setString(13,request.getParameter("impuestopatrimonio"));
 
	        ps.executeUpdate();
	        JOptionPane.showMessageDialog(null, "Sus datos se han guardado éxitosamente");
        }
        catch (Exception r){
	        JOptionPane.showMessageDialog(null,"Revise la información de los campos");
        }
    }catch (Exception e){
        JOptionPane.showMessageDialog(null,"A surgido un error en la conexion"+e);
    }
}
%>
 
 </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