HTML - Ayuda con formularios

 
Vista:

Ayuda con formularios

Publicado por Jhonatan (1 intervención) el 25/03/2015 17:57:40
Hola a todos, necesito de su gran ayuda Tengo dos formulario que trabajan entre si (page1.html y el page2.html)
en el primer formulario ingreso datos y el segundo se encarga de recuperarlos hasta ahí todo bien, el problema me surge cuando quiero que el segundo formulario se abra en una ventana nueva pues cuando lo hace ya no pasa los datos del primer formulario, por favor si alguien me podria ayudar con este problemita mio Les dejo los formularios...

page1.html
-------------------------------------------------------------------------------------------------
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
<html>
<head>
<script type="text/javascript">
<!-- 
myString="" 

function passdata(){ 
myForm=document.f1 
for(i=0;i<myForm.length-1;i++){ // run through form elements 
myString+=add_delimiters(myForm.elements[i].name,myForm.elements[i].value) // get element name and value 

location.href = 'page2.html' + '?' + escape(myString) 
} 

function add_delimiters(n,v){ 
if(n!=""){ // add = and & characters to identify name and value pairs 
return n+"="+v+"&" 
} 
} 
} 
// -->
</script>
 
 
 
</head>
<body>
 
<form name="f1" method="post" id="form-reservation" target="_blank">
Text 1 <input type="text" name="text1" value="" size="5">
Text 2 <input type="text" name="text2" value="" size="5">
Text 3 <input type="text" name="text3" value="" size="5">
Text 4 <input type="text" name="text4" value="" size="5">
Nombre: <input type="text" name="text5" value="" size="55">
 
<input name="Bot&oacute;n" type="button" onClick="passdata()" value="Bot&oacute;n">
</form>
</body>
</html>

----------------------------------------------------------------------------------------------------------------------------------------------
page2.html

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
<html>
<head>
<script type="text/javascript">
<!-- 
function getData(){ 
if (location.search.length > 0){ 
dataPassed = unescape(location.search.substring(1)) 
tempArray1=dataPassed.split("&") // split the string at character & and create an array of values 
for(i=0;i<tempArray1.length-1;i++){ // get value at array index i (name=value) 
tempArray2=tempArray1[i].split("=") // split the string at character = 
document.f1.elements["text"+(i+1)].value=tempArray2[1] // assign the value 
} 
} 
} 
//-->
</script>
</head>
<body onLoad="getData()">
<form name="f1">
Text 1 <input type="text" name="text1" size="5">
Text 2 <input type="text" name="text2" size="5">
Text 3 <input type="text" name="text3" size="5">
Text 4 <input type="text" name="text4" size="5">
Nombre: <input type="text" name="text5">
 
</form>
</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
-1
Responder