Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Passing a form field value ...

Posted on 1998-06-28
5
189 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
ID: 1844429
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
ID: 1844430
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
ID: 1844431
Sybe...are you there?

Shawn
0
 
LVL 28

Expert Comment

by:sybe
ID: 1844432
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
ID: 1844433
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Showing your events from Google Calendar in Google Maps Why? I travel all week and I thought it would be ideal if staff in office knew where I was based on my calendar. (OK real reason: my son wanted to see where I would be working, and I thoug…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

861 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