Can one include data from javascript in form

A

Andre

I am trying to help a friend with this. He run a booking site for camping
and lodges in Namibia, and if someone lands on the site He/She can select the
camping places and state the amount of days per site etc. These info is then
carried forward in JavaScript to a page containing a FrontPage Form, and
displayed on the top of the page containing the form. Because we can not
figure out how to get that information to be included in the form, He
created a Text Area in the form and then the user can just select all the
info and paste that into the text area and on submit its all send to Him.
Question: Is there a way to have the info included automatically in the
form and cutting out the copy and paste part ?

Here is is final Page:

<HTML>
<div align="center">
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" width="750"
id="table1">
<tr>
<td align="center">
<HEAD>
<TITLE>Persoonlike Besonderhede</TITLE>
</HEAD>

<BODY background="../images/bse.jpg" text="#000078">

<SCRIPT LANGUAGE="JavaScript">

// alterError - fixes a rounding bug in Netscape 2
function alterError(value) {
if (value<=0.99) {
newPounds = '0';
} else {
newPounds = parseInt(value);
}
newPence = parseInt((value+.0008 - newPounds)* 100);
if (eval(newPence) <= 9) newPence='0'+newPence;
newString = newPounds + '.' + newPence;
return (newString);
}

// showItems () - creates a table of items in the basket and
// creates the start of a form which sets information for
// basket items.
function showItems() {
index = document.cookie.indexOf("TheBasket");
countbegin = (document.cookie.indexOf("=", index) + 1);
countend = document.cookie.indexOf(";", index);
if (countend == -1) {
countend = document.cookie.length;
}
fulllist = document.cookie.substring(countbegin, countend);
totprice = 0;
document.writeln('<FORM action="bbuy04.htm" target="_top">');
document.writeln('<TABLE BORDER COLS=4>');

document.writeln('<TR><TD><b>Kampplek</b></TD><TD><b>Nagte</b></TD><TD><b>Per Nag</b></TD><td><b>Totale Koste</b></TR>');
itemlist = 0;
for (var i = 0; i <= fulllist.length; i++) {
if (fulllist.substring(i,i+1) == '[') {
itemstart = i+1;
} else if (fulllist.substring(i,i+1) == ']') {
itemend = i;
thequantity = fulllist.substring(itemstart, itemend);
itemtotal = 0;
itemtotal = (eval(theprice*thequantity));
temptotal = itemtotal * 100;
totprice = totprice + itemtotal;
itemlist=itemlist+1;
document.writeln('<tr><td>'+theitem+'</td><td
align=right>'+thequantity+'</td><td align=right>'+theprice+'</td><td
align=right>'+alterError(itemtotal)+'</td></tr>');
document.writeln('<INPUT TYPE="hidden" NAME="item'+itemlist+'"
VALUE="'+theitem+'" SIZE="40">');
document.writeln('<INPUT TYPE="hidden" NAME="quantity'+itemlist+'"
VALUE="'+thequantity+'" SIZE="40">');
document.writeln('<INPUT TYPE="hidden" NAME="price each'+itemlist+'"
VALUE="'+theprice+'" SIZE="40">');
document.writeln('<INPUT TYPE="hidden" NAME="total cost'+itemlist+'"
VALUE="'+alterError(itemtotal)+'" SIZE="40">');
} else if (fulllist.substring(i,i+1) == ',') {
theitem = fulllist.substring(itemstart, i);
itemstart = i+1;
} else if (fulllist.substring(i,i+1) == '#') {
theprice = fulllist.substring(itemstart, i);
itemstart = i+1;
}
}

document.writeln('<tr><td colspan=3><b>Groot Totaal</b></td><td
align=right>'+alterError(totprice)+'</td></tr>');
document.writeln('<INPUT TYPE="hidden" NAME="Goods Total"
VALUE="'+alterError(totprice)+'" SIZE="40">');
document.writeln('</TABLE>');

}

</SCRIPT>
<center>
<form method="POST" action="../_vti_bin/shtml.dll/viergaste/BBUY04.HTM"
onSubmit="" webbot-action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" U-File="../_private/form_results.htm"
S-Format="HTML/PRE" S-Label-Fields="TRUE" B-Reverse-Chronology="FALSE"
S-Email-Format="HTML/PRE"
S-Email-Address="(e-mail address removed)" B-Email-Label-Fields="TRUE"
B-Email-Subject-From-Field="FALSE" S-Email-Subject="Bestemming Namibië -
Afrikaanse navraag"
S-Builtin-Fields="REMOTE_NAME REMOTE_USER"
U-Confirmation-Url="BFINISH04.HTM" startspan --><input TYPE="hidden"
NAME="VTI-GROUP" VALUE="0"><!--webbot bot="SaveResults" endspan
i-checksum="43374" -->
<h2><b><font face="Verdana" color="#000078" size="4">U persoonlike
besonderhede ...</font></b></h2>

<!-- call showItems to show items in basket -->

<SCRIPT LANGUAGE="JavaScript">
showItems();
</SCRIPT>

<!-- finish off the form with other details and a /FORM tag -->

<table cols=2 id="table2">
<table cols=2 id="table2">
<tr><td colspan="2">
<p align="center"><font face="Verdana" color="#FF0000">
<b>
<u><font face="Verdana" size="2">
<table cols=2 id="table2">
<tr><td colspan="2">
<p align="center"><font face="Verdana" color="#FF0000">
<b>
<u><font face="Verdana" size="2">
BELANGRIK</font></u><font face="Verdana" size="2">!</font></b></font><font
face="Verdana" color="#FF0000" size="2"> </font><font face="Verdana"
size="2">Tot verder kennisgewing,
<u>gebruik asseblief u aanwyser ("cursor")</u> om<br>
fisies die hele tabel hierbo te kies; druk dan u muis se regterknoppie op
hierdie <br>
keuse en gebruik óf "copy & paste", óf "drag & drop" om dit binne die skadu
<br>
teksarea hieronder te plaas, voordat
u die
persoonlike besonderhede invul, <br>
en die <b>Stuur</b> knoppie <i>kliek</i>. </font><font face="Verdana"
color="#FF0000"><font size="2">
</font><font size="2" color="#FF0000"><br>
</font></font><font face="Verdana" size="2"> <font color="#FF0000">Ons vra
om verskoning
vir hierdie tydelike ongerief</font>.</font><p align="center">
<textarea rows="2" name="Itinerary" cols="60" style="background-color:
#EBE1C3"></textarea></tr>
<tr><td><INPUT TYPE="hidden" NAME="aantal in groep" VALUE="4"
SIZE="10"></td></tr>
<tr><td><font size="2" face="Verdana">Titel</font></td><td><input type=text
name="titel" size=10></td></tr>
<tr><td><font size="2" face="Verdana">Naam</font></td><td><input type=text
name="naam" size=40></td></tr>
<tr><td><font size="2" face="Verdana">E-pos adres</font></td><td><input
type=text name="epos" size=40></td></tr>
<tr><td><font size="2" face="Verdana">Dorp/Stad</font></td><td><input
type=text name="dorp" size=30></td></tr>
<tr><td><font size="2" face="Verdana">Land</font></td><td><input type=text
name="land" size=20></td></tr>
<tr><td><font size="2" face="Verdana">Telefoon</font></td><td><input
type=text name="telefoon" size=30></td></tr>
<tr><td><font size="2" face="Verdana">Beoogde
reisdatums</font></td><td><input type=text name="beoogde_reisdatums"
size=30></td></tr>
<tr><td><font size="2" face="Verdana">Kommentaar of
Vrae</font></td><td><textarea rows="2" name="Kommentaar"
cols="35"></textarea></td></tr>
</table>
<br>
<b>
<font size="2" face="Verdana" color="#FF0000">Moenie vergeet
nie</font></b><font size="2" face="Verdana">,
gebruik die "Kommentaar of Vrae" veld om ons in kennis te <br>
stel indien u meer inligting verlang, vrae beantwoord wil hê, of direkte
opdrag gee <br>
dat ons die besprekingsprosedure moet begin.</font><br>
<br>

<font face="Verdana" color="#800000" size="2"><i>Kliek</i> slegs EENMAAL op
die "Stuur" knoppie, en wag 'n paar sekondes.</font><font face="Verdana"
color="#800000" size="4"><br>
<br>
</font>

<input type="submit" value="Stuur">
<input type="reset" value="Herstel">
</td>
</tr>
</table>
</div>
<table border="0" cellpadding="0" cellspacing="0" width="750" id="table1">
<tr>
<td align="center">
</BODY>
</HTML>
 
H

Hot-text

The Beat JavaScript Editor - Ajax Editor
AT:::: http://www.yaldex.com

YES it look like this >>
BY http://www.freedback.com/
Give you something to work with !!

/////////////////////////////////////////////////////////////////
//// ////
//// CONFIRM-ORDER.HTM ////
//// ////
/////////////////////////////////////////////////////////////

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META NAME="Generator" CONTENT="TextPad 4.4">
</HEAD>

<BODY>
<center><BR><BR>
JavaScript can take the contents of an HTML order form, process them, and
display the order for verification even including the grand total! When the
user confirms the order by clicking the button, the order is emailed to you
by using freedback.com's free form processor cgi script. This script does
take a bit of modification, but surely is worth it if you sell anything
online.
<BR>
<form name=orderform action="confirm-order2.htm">
(Just check the items you wish to order.)<p>
<table border=1>
<tr>
<td>
<input type=checkbox name=item1A value="1A-Item_1_is_a_....*15.00$"></td>
<td>1A</td>
<td>Item 1 is a ....</td>
<td>$15.00</td>
</tr>
<tr>
<td>
<input type=checkbox name=item2A value="2A-Item_2_is_a_....*30.00$"></td>
<td>2A</td>
<td>Item 2 is a ....</td>
<td>$30.00</td>
</tr>
<tr>
<td>
<input type=checkbox name=item3A value="3A-Item_3_is_a_....*45.00$"></td>
<td>3A</td>
<td>Item 3 is a ....</td>
<td>$45.00</td>
</tr>
<tr>
<td colspan=4 align=center>
<input type=submit value="Order">
</td>
</tr>
</table>

/////////////////////////////////////////////////////////////////
//// ////
//// CONFIRM-ORDER2.HTM ////
//// ////
/////////////////////////////////////////////////////////////

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META NAME="Generator" CONTENT="TextPad 4.4">
<script language="JavaScript">
<!-- Begin
function decodeString()
{
valNum = new Array();
valData = new Array();
var string, length, dataCount, orderData, grandTotal;
string = "" + unescape(location.search);
string = string.substring(1,string.length);
length = location.search.length;
orderData = "";
dataCount = 1;
for (var c = 0; c < string.length; c++)
if (string.charAt(c).indexOf("&") != -1) dataCount++;

orderData = "<table border=1 width=400>";
orderData += "<tr><td>Item</td><td>Description</td><td>Cost</td></tr>";
grandTotal = 0;
for (var i = 0; i < dataCount; i++)
{
valNum = string.substring(0,string.indexOf("="));
string = string.substring(string.indexOf("=")+1,string.length);
if (i == dataCount-1) valData = string;
else valData = string.substring(0,string.indexOf("&"));
ampd = valData.indexOf("&");
pipe = valData.indexOf("-");
star = valData.indexOf("*");
line = valData.indexOf("$");
itemnum = string.substring(0,pipe);
itemdsc = string.substring(pipe+1,star);
itemcst = string.substring(star+1,line);
string = string.substring(ampd+1,string.length);

orderData += "<tr>";
orderData += "<input type=hidden name=item" + (i+1) + "num value='" +
itemnum + "'>";
orderData += "<input type=hidden name=item" + (i+1) + "dsc value='" +
itemdsc + "'>";
orderData += "<input type=hidden name=item" + (i+1) + "cst value='$" +
itemcst + "'>";
orderData += "<td>" + itemnum + "</td>";
orderData += "<td>" + itemdsc + "</td>";
orderData += "<td>" + itemcst + "</td>";
orderData += "</tr>";
grandTotal += parseInt(itemcst);
}
orderData += "<tr>";
orderData += "<td colspan=2 align=center>Total</td><td>" + grandTotal +
".00</td>";
orderData += "</tr>";
orderData += "<tr>";
orderData += "<td colspan=3 align=center><input type=submit value='Confirm
Order!'> or <a href='javascript:history.go(-1)'>Go Back</a></td>";
orderData += "</tr>";
orderData += "<input type=hidden name=grandtotal value='$" + grandTotal +
".00'>";
orderData += "</table>";
document.write(orderData);
}

function openThanks() {
window.open("confirm-order-thanks.htm");
}
// End -->
</script>
</HEAD>

<BODY onUnload="openThanks()">
<center><BR>
Here is where you confirm your order. The order is then emailed to the
webmaster using freedback.com's free form processing cgi-script.
This demo will mail the form to you if you enter your email address in the
hidden field of this script.
<BR><BR>
<form method=post action="http://cgi.freedback.com/mail.pl"
name="emailform">
<input type=hidden name=to value="(e-mail address removed)">
<input type=hidden name=subject value="** Order Form **">
<script language="JavaScript">
<!-- Begin
decodeString();
// End -->
</script>
</form>
</center>
</BODY>
</HTML>

/////////////////////////////////////////////////////////////////
//// ////
//// CONFIRM-ORDER-thank.HTM ////
//// ////
/////////////////////////////////////////////////////////////

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META NAME="Generator" CONTENT="TextPad 4.4">
</HEAD>
<BODY Background=../graphics/grayback.jpg>
<center><BR><BR><BR>
If you pressed SUBMIT, Your order has been submitted.
</center>
</BODY>
</HTML>



and doing a Debugging with JS Syntax Check on the HTML you Posted >>> Line
57 Column 37 Error: Syntax error



Andre said:
I am trying to help a friend with this. He run a booking site for camping
and lodges in Namibia, and if someone lands on the site He/She can select
the
camping places and state the amount of days per site etc. These info is
then
carried forward in JavaScript to a page containing a FrontPage Form, and
displayed on the top of the page containing the form. Because we can not
figure out how to get that information to be included in the form, He
created a Text Area in the form and then the user can just select all the
info and paste that into the text area and on submit its all send to Him.
Question: Is there a way to have the info included automatically in the
form and cutting out the copy and paste part ?

Here is is final Page:

<HTML>
<div align="center">
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" width="750"
id="table1">
<tr>
<td align="center">
<HEAD>
<TITLE>Persoonlike Besonderhede</TITLE>
</HEAD>

<BODY background="../images/bse.jpg" text="#000078">

<SCRIPT LANGUAGE="JavaScript">

// alterError - fixes a rounding bug in Netscape 2
function alterError(value) {
if (value<=0.99) {
newPounds = '0';
} else {
newPounds = parseInt(value);
}
newPence = parseInt((value+.0008 - newPounds)* 100);
if (eval(newPence) <= 9) newPence='0'+newPence;
newString = newPounds + '.' + newPence;
return (newString);
}

// showItems () - creates a table of items in the basket and
// creates the start of a form which sets information for
// basket items.
function showItems() {
index = document.cookie.indexOf("TheBasket");
countbegin = (document.cookie.indexOf("=", index) + 1);
countend = document.cookie.indexOf(";", index);
if (countend == -1) {
countend = document.cookie.length;
}
fulllist = document.cookie.substring(countbegin, countend);
totprice = 0;
document.writeln('<FORM action="bbuy04.htm" target="_top">');
document.writeln('<TABLE BORDER COLS=4>');

document.writeln('<TR><TD><b>Kampplek</b></TD><TD><b>Nagte</b></TD><TD><b>Per
Nag</b></TD><td><b>Totale Koste</b></TR>');
itemlist = 0;
for (var i = 0; i <= fulllist.length; i++) {
if (fulllist.substring(i,i+1) == '[') {
itemstart = i+1;
} else if (fulllist.substring(i,i+1) == ']') {
itemend = i;
thequantity = fulllist.substring(itemstart, itemend);
itemtotal = 0;
itemtotal = (eval(theprice*thequantity));
temptotal = itemtotal * 100;
totprice = totprice + itemtotal;
itemlist=itemlist+1;
document.writeln('<tr><td>'+theitem+'</td><td
align=right>'+thequantity+'</td><td align=right>'+theprice+'</td><td
align=right>'+alterError(itemtotal)+'</td></tr>');
document.writeln('<INPUT TYPE="hidden" NAME="item'+itemlist+'"
VALUE="'+theitem+'" SIZE="40">');
document.writeln('<INPUT TYPE="hidden" NAME="quantity'+itemlist+'"
VALUE="'+thequantity+'" SIZE="40">');
document.writeln('<INPUT TYPE="hidden" NAME="price each'+itemlist+'"
VALUE="'+theprice+'" SIZE="40">');
document.writeln('<INPUT TYPE="hidden" NAME="total cost'+itemlist+'"
VALUE="'+alterError(itemtotal)+'" SIZE="40">');
} else if (fulllist.substring(i,i+1) == ',') {
theitem = fulllist.substring(itemstart, i);
itemstart = i+1;
} else if (fulllist.substring(i,i+1) == '#') {
theprice = fulllist.substring(itemstart, i);
itemstart = i+1;
}
}

document.writeln('<tr><td colspan=3><b>Groot Totaal</b></td><td
align=right>'+alterError(totprice)+'</td></tr>');
document.writeln('<INPUT TYPE="hidden" NAME="Goods Total"
VALUE="'+alterError(totprice)+'" SIZE="40">');
document.writeln('</TABLE>');

}

</SCRIPT>
<center>
<form method="POST" action="../_vti_bin/shtml.dll/viergaste/BBUY04.HTM"
onSubmit="" webbot-action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" U-File="../_private/form_results.htm"
S-Format="HTML/PRE" S-Label-Fields="TRUE" B-Reverse-Chronology="FALSE"
S-Email-Format="HTML/PRE"
S-Email-Address="(e-mail address removed)" B-Email-Label-Fields="TRUE"
B-Email-Subject-From-Field="FALSE" S-Email-Subject="Bestemming Namibië -
Afrikaanse navraag"
S-Builtin-Fields="REMOTE_NAME REMOTE_USER"
U-Confirmation-Url="BFINISH04.HTM" startspan --><input TYPE="hidden"
NAME="VTI-GROUP" VALUE="0"><!--webbot bot="SaveResults" endspan
i-checksum="43374" -->
<h2><b><font face="Verdana" color="#000078" size="4">U persoonlike
besonderhede ...</font></b></h2>

<!-- call showItems to show items in basket -->

<SCRIPT LANGUAGE="JavaScript">
showItems();
</SCRIPT>

<!-- finish off the form with other details and a /FORM tag -->

<table cols=2 id="table2">
<table cols=2 id="table2">
<tr><td colspan="2">
<p align="center"><font face="Verdana" color="#FF0000">
<b>
<u><font face="Verdana" size="2">
<table cols=2 id="table2">
<tr><td colspan="2">
<p align="center"><font face="Verdana" color="#FF0000">
<b>
<u><font face="Verdana" size="2">
BELANGRIK</font></u><font face="Verdana" size="2">!</font></b></font><font
face="Verdana" color="#FF0000" size="2"> </font><font face="Verdana"
size="2">Tot verder kennisgewing,
<u>gebruik asseblief u aanwyser ("cursor")</u> om<br>
fisies die hele tabel hierbo te kies; druk dan u muis se regterknoppie op
hierdie <br>
keuse en gebruik óf "copy & paste", óf "drag & drop" om dit binne die
skadu
<br>
teksarea hieronder te plaas, voordat
u die
persoonlike besonderhede invul, <br>
en die <b>Stuur</b> knoppie <i>kliek</i>. </font><font face="Verdana"
color="#FF0000"><font size="2">
</font><font size="2" color="#FF0000"><br>
</font></font><font face="Verdana" size="2"> <font color="#FF0000">Ons
vra
om verskoning
vir hierdie tydelike ongerief</font>.</font><p align="center">
<textarea rows="2" name="Itinerary" cols="60" style="background-color:
#EBE1C3"></textarea></tr>
<tr><td><INPUT TYPE="hidden" NAME="aantal in groep" VALUE="4"
SIZE="10"></td></tr>
<tr><td><font size="2" face="Verdana">Titel</font></td><td><input
type=text
name="titel" size=10></td></tr>
<tr><td><font size="2" face="Verdana">Naam</font></td><td><input type=text
name="naam" size=40></td></tr>
<tr><td><font size="2" face="Verdana">E-pos adres</font></td><td><input
type=text name="epos" size=40></td></tr>
<tr><td><font size="2" face="Verdana">Dorp/Stad</font></td><td><input
type=text name="dorp" size=30></td></tr>
<tr><td><font size="2" face="Verdana">Land</font></td><td><input type=text
name="land" size=20></td></tr>
<tr><td><font size="2" face="Verdana">Telefoon</font></td><td><input
type=text name="telefoon" size=30></td></tr>
<tr><td><font size="2" face="Verdana">Beoogde
reisdatums</font></td><td><input type=text name="beoogde_reisdatums"
size=30></td></tr>
<tr><td><font size="2" face="Verdana">Kommentaar of
Vrae</font></td><td><textarea rows="2" name="Kommentaar"
cols="35"></textarea></td></tr>
</table>
<br>
<b>
<font size="2" face="Verdana" color="#FF0000">Moenie vergeet
nie</font></b><font size="2" face="Verdana">,
gebruik die "Kommentaar of Vrae" veld om ons in kennis te <br>
stel indien u meer inligting verlang, vrae beantwoord wil hê, of direkte
opdrag gee <br>
dat ons die besprekingsprosedure moet begin.</font><br>
<br>

<font face="Verdana" color="#800000" size="2"><i>Kliek</i> slegs EENMAAL
op
die "Stuur" knoppie, en wag 'n paar sekondes.</font><font face="Verdana"
color="#800000" size="4"><br>
<br>
</font>

<input type="submit" value="Stuur">
<input type="reset" value="Herstel">
</td>
</tr>
</table>
</div>
<table border="0" cellpadding="0" cellspacing="0" width="750"
id="table1">
<tr>
<td align="center">
</BODY>
</HTML>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top