Solved

Passing a form field value ...

Posted on 1998-06-28
5
187 Views
Last Modified: 2010-04-09
Hi...
  I've got the following very simple HTML for when I click a 'Click Here' button (I have a form action statement at the beginning of my HTML with the script that it invokes):

<INPUT TYPE="hidden" NAME="CUSTID"
VALUE="3205"><INPUT TYPE="hidden" NAME="LOGIN"
VALUE="jsmith"><INPUT TYPE="hidden" NAME="AMOUNT"
VALUE="50.00"><INPUT TYPE="hidden" NAME="DESCRIPTION"
VALUE="Click Here">

..What I'd LIKE to have ideally is to just have a little form right above this 'Click Here' button ,where the user could simply enter any dollar amount, then this amount would be passed to the 'NAME="AMOUNT" VALUE="50.00"' field. So that the number they enter would be substituted for the "50.00"...Can this be done?

Thanks
  Shawn Halfpenny
  drumme59@sprint.ca
0
Comment
Question by:aztec
  • 3
  • 2
5 Comments
 
LVL 28

Accepted Solution

by:
sybe earned 50 total points
Comment Utility
1. give the form a name:

<form name="anExample" action="  ">

2. make the textfield
<input type="text" name="fill" onChange="ChangeHiddenField(document.anExample.fill.value)"

3. include the javascript that changes the hidden field

<script>
function ChangeHiddenField(string) {
 document.anExample.AMOUNT.value = string;
}
</script>

- You can include some verifying in the function, to see if it is really a number

- But why don't you just use the text field ? Why a hidden field ?

0
 

Author Comment

by:aztec
Comment Utility
ummm Sybe...you are confusing me. OK, I will explain FULLY my situation: I am implementing a method of accepting on-line credit card payment known as "magic button". Usually, the user simply clicks the "Magic Button", and the data hard-coded in the HTML (price, etc.) gets sent to the Magic Button server for processing. This is all fine. However we do not have a set price that we can simply hard-code into the HTML and leave like that...we charge various prices. That's why would we would like to have a little form field where we can simply type in our desired price and it gets carried on to the Magic Button server for processing (...instead we would have to hard-code each different price into the HTML each time...too time consuming)
  Consider too, I know nothing about CGI programming and Java! I am merely using the HTML code that the Magic Button people said to simply cut and paste and insert in my own web page...changing only the desired price and my ID #.
  Here is the HTML that I inserted as per their sample on their website:

<FORM action="https://www.authorize.net/scripts/authnet25/WebLink.asp" method="POST">


<P><CENTER>If you agree with the above terms and conditions, click
the Magic Button! <INPUT TYPE="hidden" NAME="CUSTID"
VALUE="3205"><INPUT TYPE="hidden" NAME="LOGIN"
VALUE="mgordon"><INPUT TYPE="hidden" NAME="AMOUNT"
VALUE="50.00"><INPUT TYPE="hidden" NAME="DESCRIPTION"
VALUE="Magic Button"></CENTER></P>

<P><CENTER><INPUT TYPE="submit" NAME="jack russell"
VALUE="Magic Button">
<HR>

.I simply want to be able to input a price into a field, and have that price be used in place of the VALUE="50.00", that you see up above. I hope this makes things clearer!

Cheers
   Shawn Halfpenny
   drumme59@sprint.ca

P.S: Please see their example at http://www.myfreeoffice.com/takevisa/magic.html
0
 

Author Comment

by:aztec
Comment Utility
Sybe...are you there?

Shawn
0
 
LVL 28

Expert Comment

by:sybe
Comment Utility
yeah i am here, but i am going to sleep, since I am in Europe. I will have a look at it tomorrow.
0
 
LVL 28

Expert Comment

by:sybe
Comment Utility
I see what you want.

The thing is that the CGI does not care if the formfield is text, hidden or whatever, what only counts is the name and the value.

So if you have a form, and you need a pass a value for AMOUNT, then you can just create a text field with the name AMOUNT and in your case not use a hidden field with the name AMOUNT.

You can make a text field with the name AMOUNT like this:

<input type="text" name="AMOUNT">

IS this closer to what you need ?
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Javascript - getdate 5 49
Swiper slider stops between pages 11 29
Condidional <a href = ....> 1 22
using web browser with BING 40 80
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
In this tutorial viewers will learn how add a full-size background image to a webpage using CSS3. Create a new HTML document with an internal stylesheet.: In CSS, define the html element to have a background image. Use a high resolution image.: In t…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now