Welcome to WebmasterWorld Guest from

Forum Moderators: incrediBILL

Message Too Old, No Replies

Asigning value to text box if used



1:50 am on Jul 19, 2010 (gmt 0)

5+ Year Member

I'm trying to make an ordering page where my clients would enter in a image code "L5648"

If a code was entered into a form text box, it would save the image code value as well assign a new value of $6.00 so further down the page, the form would calculate the order total.

So. if 4 image codes were entered I would have 4 values of "6.00" each.

Is this possible?

(See the "Unaltered images burned to cd")

Thanks in advance.

Site is in test mode so play if you would like.


3:19 am on Jul 20, 2010 (gmt 0)

Not with HTML. HTML is a static language. You would need a server-side scripting language. Might look into installing an eCommerce package which has an "Add to Cart" function. Alternative is to check PayPal and see what they provide for a Cart function on a web site.



6:19 am on Jul 20, 2010 (gmt 0)

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

Welcome to the forums, Dave. Major_Payne speaks the truth!


7:34 am on Jul 21, 2010 (gmt 0)

WebmasterWorld Senior Member dreamcatcher is a WebmasterWorld Top Contributor of All Time 10+ Year Member

I`m not sure he`s asking about a cart option, but rather a way for the form to total itself up automatically before the pay button is clicked?

Look into javascript/ajax.



3:54 pm on Jul 21, 2010 (gmt 0)

5+ Year Member

I've been working on some code someone gave me on another forum but can't quite get it.

I think I'm having a problem striping out the first letter in the "cd" box.
var re = substr("cd"+c, -4);

The boxes will be populated with image codes like: L5487, S5487, D5487 and T6542.

Sorry if this should be in the java section, I started out with thinking it was a html format problem.

<script type="text/javascript">
function getCdCost( )
var re = substr("cd"+c, -4);
var form = document.selectionForm;
var count = 0;
for ( var c = 1; c < 9999; ++c )
var fld = form.elements["cd"+c];
if ( fld == null ) break; // out of loop when no more
var val = fld.value.replace(/\s/g,""); // zap spaces
if ( val != "" )
if ( re.test( val ) ) ++count;
} else {
alert( "Invalid L number: " + fld.value );
var cost = 0;
if ( count > 0 ) cost = 23 + 6 * ( count - 1 );

<form method="POST" name="selectionForm" action="sendform.php">
<input type="text" name="cd1" size="3" maxlength="5" onchange="getCdCost();this.form.SUBMIT.focus();"><br/>
<input type="text" name="cd2" size="3" maxlength="5" onchange="getCdCost();this.form.SUBMIT.focus();"><br/>
<input type="text" name="cd3" size="3" maxlength="5" onchange="getCdCost();this.form.SUBMIT.focus();"><br/>
<input type="text" name="cd4" size="3" maxlength="5" onchange="getCdCost();this.form.SUBMIT.focus();"><br/>
<input type="text" name="total" readonly>
<input type="submit" value="Submit">

Featured Threads

Hot Threads This Week

Hot Threads This Month