/    Sign up×
Community /Pin to ProfileBookmark

Urgent help with simple passing of form values

I was wondering is anyone could help me urgently with a problem i’m having with receiving form values from another form. The values are being sent but for some reason unknown to me they are shown on the page.

The code i have so far for the first page is:
<form type=”get” action=”passing-values-source.html”>
<td width=”100%” align=”left” valign=”middle” bgcolor=”#FFFFFF”> <table width=”100%” border=”0″ cellspacing=”0″ cellpadding=”4″ bgcolor=”#FFFFFF”>
<tr valign=”middle”>
<td width=”30%” align=”right” valign=”top” nowrap> <a class=”order”>Product:
</a></td>
<td width=”70%” valign=”top”> <textarea name=”product” rows=4 wrap=nowrap cols=40 value””></textarea>
</td>
</tr>
<tr valign=”middle”>
<td width=”30%” nowrap align=”right” valign=”top”><a class=”order”>
Size<font face=”Verdana, Arial, Helvetica, sans-serif” size=”1″ color=”#000000″>
(if applicable)</font>:</a></td>
<td width=”70%”> <input maxlength=50 size=30 name=”size” value=””> </td>
</tr>
<tr valign=”middle”>
<td width=”30%” nowrap align=”right”> <a class=”order”>Price:</a> </td>
<td width=”70%”><input type=”text” name=”price” value=”0.00″> </td>
</tr>
<tr>
<td width=”30%” nowrap align=”right” valign=”top” class=small> <a class=”order”>Quantity:</a>
</td>
<td width=”70%” valign=”top”><input type=”text” name=”quantity” value=”1″>
</td>
</tr>
<tr>
<td><img src=”blank.gif” height=”10″> </td>
<td><img src=”blank.gif” height=”10″> </td>
</tr>
<tr>
<td align=”center” valign=”middle”> <input type=”submit” class=”button” value=”Submit” name=”submit”>
</td>
<td align=”center” valign=”middle”> <input class=”button” type=”reset” value=”Reset” name=”reset”>
</td>
</tr>
</form>

The code for the page recieving the info goes something like:

<head>
<script>
<!– Begin
function getParams() {
var idx = document.URL.indexOf(‘?’);
var params = new Array();
if (idx != -1) {
var pairs = document.URL.substring(idx+1, document.URL.length).split(‘&’);
for (var i=0; i<pairs.length; i++) {
nameVal = pairs[i].split(‘=’);
params[nameVal[0]] = nameVal[1];
}
}
return params;
}
params = getParams();
// End –>

function round_total (c) {
var pennies = c * 100;
pennies = Math.round(pennies);
var strPennies = “” + pennies;
var len = strPennies.length;
return parseFloat(strPennies.substring(0, len – 2) + “.” + strPennies.substring(len – 2, len));
}

tax = 0.40;
delivery_p = 5.99;
var odate = new Date();
var qty = form.quantity.value;
var sze = form.size.value;
var product_v = “product”;
var total_price = price.value;
var price_without_tax = round_total(qty * total_price);
var ttax = round_total(price_without_tax * tax);
var delivery = round_total(qty * delivery_p);
var total_p = round_total(price_without_tax + ttax + delivery);

</script>
</head>
<body>
<SCRIPT LANGUAGE=”JavaScript”>

<!– Begin

product = unescape(params[“product”]);
size = unescape(params[“size”]);
price = unescape(params[“price”]);
quantity = unescape(params[“quantity”]);

document.writeln(“Product: ” + product_v + “<br>”);
document.writeln(“Quantity: ” + qty + “<br>”);
document.writeln(“Size: ” + sze + “<br>”);
document.writeln(“Price: £” + total_price + “<br>”);
document.writeln(“Tax: £” + ttax + “<br>”);
document.writeln(“Delivery: £” + delivery + “<br>”);
document.writeln(“Total: £” + total_p + “<br>”);
document.writeln(“Order placed on: ” + odate.toGMTString());

// End –>
</script>
</body>

Any suggestions?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@simpson97Apr 16.2004 — This should work:

<html>

<head>

<script type="text/javascript">

//<![CDATA[

function getParams()

{

if(document.URL.indexOf('?'))

{

var params = new Array();

var pairs = document.location.search.substring(1, document.location.search.length).split('&');

for (var i = 0; i < pairs.length; i++) {

nameVal = pairs[i].split('=');

params[nameVal[0]] = nameVal[1];

}

}

return params;

}

function round_total (c)

{

var pennies = c * 100;

pennies = Math.round(pennies);

var strPennies = "" + pennies;

var len = strPennies.length;

return parseFloat(strPennies.substring(0, len - 2) + "." + strPennies.substring(len - 2, len));

}

params = getParams();

tax = 0.40;

delivery_p = 5.99;

var odate = new Date();

var qty = unescape(params['quantity']);

var total_price = unescape(params['price']);

var price_without_tax = round_total(qty *
total_price);

var ttax = round_total(price_without_tax * tax);

var delivery = round_total(qty *
delivery_p);

var total_p = round_total(price_without_tax + ttax + delivery);

//]]>

</script>

</head>

<body>

<script type="text/javascript">

//<![CDATA[

product = unescape(params["product"]);

size = unescape(params["size"]);

document.writeln("Product: " + product + "<br>");

document.writeln("Quantity: " + qty + "<br>");

document.writeln("Size: " + size + "<br>");

document.writeln("Price: £" + total_price + "<br>");

document.writeln("Tax: £" + ttax + "<br>");

document.writeln("Delivery: £" + delivery + "<br>");

document.writeln("Total: £" + total_p + "<br>");

document.writeln("Order placed on: " + odate.toGMTString());

//]]>

</script>

</body>



Bob
×

Success!

Help @kittykat spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...