Porównaj ceny domen i usług IT, sprzedawców z całego świata

Prześlij wiele formularzy za pomocą jednego przycisku Prześlij


Mam następujący kod, w zasadzie robi dwie rzeczy. Pierwsza z nich to przesyłanie danych arkusza kalkulacyjnego Google i inne operacje polegające na przesłaniu mojej drugiej wartości pola tekstowego formularza do innego pola tekstowego wartości strony. Jak to zrobić?
<script type="text/javascript"><!--
function copy_data(val){
var a = document.getElementById(val.id).value
document.getElementById("copy_to").value=a
}
//-->
</SCRIPT>
<style type="text/css">
<!--
-->
</style></head>
<body >
<script type="text/javascript">var submitted=false;</script>
<iframe name="response_iframe" id="hidden_iframe" style="display:none;" onload="if(submitted){window.location='Thanks.asp';}"></iframe> <form action="[url=https://docs.google.com/spreadsheet/formResponse?formkey=dGtzZnBaYTh4Q1JfanlOUVZhZkVVUVE6MQ&ifq"]https://docs.google.com/spread ... ot%3B[/url] method="post" target="response_iframe" id="commentForm" onSubmit="submitted=true;"><!-- #include virtual="/sts/include/header.asp" -->
<!-- ABove this Header YJC -->
<table style="background-color: #FFC ;" width="950" align="center" border="0" summary="VanaBhojnaluBooking_Table">
<tr><td colspan="7"><p class="MsoNormal" align="center" style="text-align:center;">[b]<span style="line-height:115%; font-family:'Arial Rounded MT Bold','sans-serif'; font-size:16.0pt; color:#76923C; ">Karthika Masa Vanabhojanalu &ndash; Participation Booking</span>[/b]<p class="MsoNormal" align="center" style="text-align:center;">[b]<span style="line-height:115%; font-size:20.0pt; color:#7030A0; ">13<sup>th</sup> Nov 2011 - @ West Coast Park - Singapore</span>[/b] <p class="MsoNormal" align="center" style="text-align:center;">[b]<span style="color:#7030A0; ">Reserve your participation and avail </span><span style="color:red; "> <a target="_blank" href="/STS/programs/VB_2011_info.asp"> DISCOUNT [/url]</span><span style="color:#7030A0; "> on the ticket</span>[/b]</td> </tr>
<tr>
<th width="37" scope="col">&nbsp;</th>
<th width="109" rowspan="5" valign="top" class="YJCRED" scope="col"><div align="left"><font size="2"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;* Required</font></th>
<td width="68" scope="col"><div align="right"><font size="2.5px">Name</font><span class="yj"><span class="yjcred">*</span></span></td>
<th colspan="3" scope="col"><label for="Name"></label>
<div align="left">
<input name="entry.0.single" class="required" style="width:487px; height:25px; vertical-align:middle;" type="text" id="entry_0" title="Enter your name" >
</th>
<th width="223" scope="col">&nbsp;</th>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right"><font size="2.5px">Phone</font><span class="yj"><span class="yjcred">*</span></span></td>
<td width="107"><input name="entry.1.single" class="required" title="Handphone Number with out +65" maxlength="8" style="width:100px;height:25px;" type="text" onkeyup="copy_data(this)" onKeyPress="return numbersonly(this, event)" id="entry_1" ></td>
<td width="170"><div align="right"><font size="2.5px">Email</font><span class="yj"><span class="yjcred1">*</span></span></td>
<td width="206"><input name="entry.2.single" type="text" style="width:190px;height:25px;" id="required" title="Enter your email address" class="required email" ></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right"><font size="2.5px">Home Phone</font></td>
<td width="107"><input name="entry.1.single" title="Handphone Number with out +65" maxlength="8" style="width:100px;height:25px;" type="text" onKeyPress="return numbersonly(this, event)" id="entry_100" ></td> </tr>
<tr>
<td align="center" colspan="7">&nbsp;
<input type="submit" name="submit" onMouseOver="Window.status='You can not see anything';return true" onMouseOut="window.status='Press SUBMIT only after proper inforatmion entering then you are Done'" onClick="jQuery.Watermark.HideAll();" value="Submit">
&nbsp;</td>
</tr>
&nbsp; <tr>
<td colspan="25"></td>
</tr>
</table></form>
<form method="Link" Action="Sankranthi_Reserv2.asp">
<input disabled name="copy of hp" maxlength="8" style="width:100px;height:25px;" type="text" id="copy_to" ></form>
<!-- #include virtual="/sts/include/footer.asp" --> <input type="hidden" name="pageNumber" value="0">
<input type="hidden" name="backupCache" value="">
<script type="text/javascript"> (function() {
var divs = document.getElementById('ss-form').
getElementsByTagName('div');
var numDivs = divs.length;
for (var j = 0; j < numDivs; j++) {
if (divs[j].className == 'errorbox-bad') {
divs[j].lastChild.firstChild.lastChild.focus();
return;
}
}
for (var i = 0; i < numDivs; i++) {
var div = divs[i];
if (div.className == 'ss-form-entry' &&
div.firstChild &&
div.firstChild.className == 'ss-q-title') {
div.lastChild.focus();
return;
}
}

Jak widać powyżej, jest to pierwsza strona i druga strona, na której miałem na myśli Sankranthi_Reserv2.asp w drugiej formie. Chcę tam przekazać wartość pola tekstowego, więc problem polega na tym, że pierwszy formularz przesyła dane do google docs i przechowuje je, a drugi formularz musi przekazać wartość numeru telefonu pola tekstowego do pola tekstowego NASTĘPNA STRONA, ale jest tylko jeden Przycisk WYŚLIJ.
Zaproszony:
Anonimowy użytkownik

Anonimowy użytkownik

Potwierdzenie od:

Będziesz musiał użyć Ajax, aby przesłać dwa formularze. Podobnie jak po użyciu form.submit (), strona załaduje akcję URL dla tego formularza. więc musisz to zrobić asynchronicznie.
Możesz więc przesłać oba żądania asynchronicznie lub możesz przesłać jedno żądanie asynchronicznie, a po pomyślnym przesłaniu drugiego formularza.
function submitTwoForms() {
var dataObject = {"form1 Data with name as key and value "};
$.ajax({
url: "test.html",
data : dataObject,
type : "GET",
success: function(){
$("#form2").submit();//assuming id of second form is form2
}
});
return false;//to prevent submit
}

Możesz powiązać tę funkcję
submitTwoForms ()
z pojedynczym przyciskiem przesyłania. Przez
$('#form1').submit(function() {
submitTwoForms();
return false;
});

Ale jeśli nie chcesz tego wszystkiego robić, możesz użyć

wtyczka formularza jquery
http://jquery.malsup.com/form/#getting-started
aby przesłać formularz za pomocą Ajax.
Anonimowy użytkownik

Anonimowy użytkownik

Potwierdzenie od:

Coś takiego zadziałałoby:
$('#form1_submit_button').click(function(){
$('form').each(function(){
$(this).submit();
});
});

Alternatywny:
$('#form1_submit_button').click(function(){
$('#form1 #form2 #form3').submit();
});
Anonimowy użytkownik

Anonimowy użytkownik

Potwierdzenie od:

Najłatwiejszy sposób, jaki znalazłem, to coś takiego
<form method='post' action='whatever?whatever1=blah&whatever2=blah'>
<?php
header ("Location: [url=http://example.com/whatever.html"]http://example.com/whatever.html"[/url];);
?>

Spowoduje to, że formularz będzie działał (nie pokazując go w przeglądarce), a następnie przekieruje do strony nagłówkowej.

Aby odpowiedzieć na pytania, Zaloguj się lub Zarejestruj się