469,356 Members | 1,994 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,356 developers. It's quick & easy.

Issue with setting hidden value from url

Hi All,

I'm not too proficient in Javascript but am trying to help a friend
out. Bascially, the page we are having trouble with is loaded with a
numerical value in the url string. Example:

http://www.webpage.com/v4/payment_pg...cimal%20=49.50

I then parse the string to get the total. I then want to assign the
value to a hidden form value
(document.form1.FeeCalcTotalDecimal.value) The hidden value is to be
used to post to a bank's website.

I'm sure this is just a syntax issue, but I'm stumped. Keep getting
"document.form1.FeeCalcTotalDecimal.value is null or not an object."

<CODE>

<script language="JavaScript">

function parseGetVars() {
var getVars = new Array();
var qString = unescape(top.location.search.substring(1));
var pairs = qString.split(/\&/);
for (var i in pairs) {
var nameVal = pairs[i].split(/\=/);
getVars[nameVal[0]] = nameVal[1];
}
return getVars;
}
</script>

<script>
var g = parseGetVars();
for (var i in g)
document.writeln('Your total fee is $' +g[i]+'<br>');
document.form1.FeeCalcTotalDecimal.value = '+g[i]+' ; THIS ISN'T
WORKING!!
</script>
<br />
</font</div>
<table width="715" height="52" border="0">
<tr>
<td align="center" width="374" height="48"<form
name="form1" method="post" action="https://secure.linkpt.net/lpcentral/
servlet/lppay">
<input type="hidden" name="txntype" value="sale">
<input type="hidden" name="storename" value="1001184858">
<INPUT type="hidden" name="chargetotal"
value="FeeCalcTotalDecimal">
<input type="hidden" name="suppressTitle" value="true">
<input name="Submit" type="submit" id="Submit" value="Submit">
</td>
<td width="331">
</div>
</form></td>
</tr>
</table>

</CODE>

Thanks in advance for your help!

JCC
Jun 27 '08 #1
3 1081
JCCDevel wrote:
I'm not too proficient in Javascript but am trying to help a friend
out.
FOAF? Yeah, sure ;-)
[...]
I then parse the string to get the total. I then want to assign the
value to a hidden form value
(document.form1.FeeCalcTotalDecimal.value) The hidden value is to be
used to post to a bank's website.

I'm sure this is just a syntax issue, but I'm stumped. Keep getting
"document.form1.FeeCalcTotalDecimal.value is null or not an object."
The script is located before the control in the markup; the control does
not exist at that point. Besides, your markup is not Valid[1] and you are
using proprietary syntax. Use instead, after the control was parsed:

document.forms["form1"].elements["FeeCalcTotalDecimal"].value

[1] http://validator.w3.org/
HTH

PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Jun 27 '08 #2
JCCDevel wrote on 17 apr 2008 in comp.lang.javascript:
document.form1.FeeCalcTotalDecimal.value = '+g[i]+' ; THIS ISN'T
WORKING!!
reason1:

The form form1 is not yet declared and so not yet part of the DOM.

reason2:

<INPUT type="hidden" name="chargetotal"
value="FeeCalcTotalDecimal">

Should be something like:

<INPUT type="hidden" name="FeeCalcTotalDecimal"
value="">
=============================

Why use outmoded
<script language="JavaScript">
and
<script>
where
<script type='text/javascript'>
is the standard?

Why split the script in two?

Change 1
document.form1.
to
document.forms.form1.

<table width="715" height="52" border="0">
use css styles instead!

In the end,
better fill the hidden input with serverside code.
ASP example:

<INPUT type="hidden" name="FeeCalcTotalDecimal"
value = '<% = serversideValue %>'>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jun 27 '08 #3
On Apr 17, 12:05*pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
JCCDevel wrote:
I'm not too proficient in Javascript but am trying to help a friend
out.

FOAF? *Yeah, sure ;-)
[...]
I then parse the string to get the total. I then want to assign the
value to a hidden form value
(document.form1.FeeCalcTotalDecimal.value) The hidden value is to be
used to post to a bank's website.
I'm sure this is just a syntax issue, but I'm stumped. *Keep getting
"document.form1.FeeCalcTotalDecimal.value is null or not an object."

The script is located before the control in the markup; the control does
not exist at that point. *Besides, your markup is not Valid[1] and you are
using proprietary syntax. *Use instead, after the control was parsed:

* document.forms["form1"].elements["FeeCalcTotalDecimal"].value

[1]http://validator.w3.org/

HTH

PointedEars
--
* * realism: * *HTML 4.01 Strict
* * evangelism: XHTML 1.0 Strict
* * madness: * *XHTML 1.1 as application/xhtml+xml
* * * * * * * * * * * * * * * * * * * * * * * * * * -- Bjoern Hoehrmann
Thank you both for your suggestions. I have asked my friend(and yes
Thomas, it is for a friend - she is strictly a designer and hasn't had
to do this type of thing before) to plug this into her page. I'm used
to using server side code and her page is just stand-alone. I truly
appreciate your help!
Jun 27 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Jim | last post: by
1 post views Thread by Rob Meade | last post: by
9 posts views Thread by PK9 | last post: by
4 posts views Thread by PJ6 | last post: by
3 posts views Thread by rob c | last post: by
reply views Thread by bruce | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.