473,387 Members | 3,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 1212
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jim | last post by:
I have a 2 checkboxes and a hidden field..what I want to happen is that you can only click on 1 of these checkboxes at a time and when you check a checkbox it will assign the hidden field...
1
by: Rob Meade | last post by:
Hi all, I have a loop in my code which builds the controls on the page. I at one stage need to add some hidden input controls dynamically, I have achieved this, and I have set their...
9
by: PK9 | last post by:
I'm having an issue with the "Refresh" of an asp.net page. The refresh is actually calling my last onClick event. I thought that asp.net was supposed to be stateless in that it shouldn't...
4
by: PJ6 | last post by:
From a control's onkeypress the below javascript snippet is executed. I am attmpting to set the value of a hidden field... I believe I'd be able to get the contents of the hidden field by using...
1
by: Harshal P | last post by:
Hello, I am settings hidden field value from the DayRender event hadler of the asp.net calendar control, when i try to read the value of hidden field from javascript, the value is empty string. If...
3
by: rob c | last post by:
Hi I'm not sure if this is the right place to ask for help on forms and radio buttons... In the following form, I'd like to set the value of 'item_name' based on which radio button was...
0
by: bruce | last post by:
hi... it appears that i'm running into a possible problem with mechanize/browser/python rgarding the "select_form" method. i've tried the following and get the error listed: br.select_form(nr...
2
by: corykendall | last post by:
Here is my code: ... Setting hidden input to: <dsp:valueof param="tabname"/> <input name="tabname" type="hidden" value='<dsp:valueof param="tabname"/>'/> </dsp:form> hidden input set...
1
by: worldofrugs | last post by:
I'm hosted on a shared server with Godaddy.com... I have several forms on my website that all use the same ASP file to send out my forms.. It worked fine for a long time, but now the forms send to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.