PDA

View Full Version : seems like basic form question about hidden fields



howardfan123
Mar 4th, 2010, 04:20 PM
I have two check boxes and a few hidden fields with text boxes attached to them. how do i keep them from posting to my shopping cart if not filled in or checked.



<p><span class="style30">Send directly to recipant:</span><input name="product3[]" type="checkbox" value="{br}{b}SEND CERT DIRECTLY TO RECIPANT---{/b}" onclick="toggle(this, 'shipGroup');"/><br/>
<center><span class="style30">Send to me to give to recipant:</span>
<input name="product3[]" type="checkbox" value="{br}{b}SEND CERT TO ME TO GIVE TO RECIPANT---{/b}" /></center></P>
<input type="hidden" name="price3" value=".00" />
<input type="hidden" name="qty3" value="1" />
<input type="hidden" name="noqty3" value="3" />
<p><div id="shipGroup" align="left">
<span class="style30">First Name</span>
<input type="hidden" name="product3[]" value="{br}FIRST NAME:" />
<input type="text" name="product3[]" value=""/>
<span class="style30">Last Name</span>
<input type="hidden" name="product3[]" value="{br}LAST NAME:" />
<input type="text" name="product3[]" value=""/><br/>
<span class="style30">Address</span>
<input type="hidden" name="product3[]" value="{br}ADDRESS:" />
<input type="text" name="product3[]" value=""/><br/>
<span class="style30">City</span>
<input type="hidden" name="product3[]" value="{br}CITY:" />
<input type="text" name="product3[]" value=""/><br/>
<span class="style30">State</span>
<input type="hidden" name="product3[]" value="{br}STATE:" />
<input type="text" name="product3[]" value="" size="10"/>
<span class="style30">Zip code</span>
<input type="hidden" name="product3[]" value="{br}ZIP CODE:" />
<input type="text" name="product3[]" value="" size="5"/></div></p>

zen-angel
Mar 4th, 2010, 04:28 PM
why do you have hidden fields and text fields with the same name attribute?

unless you use javascript, your form will always submit all its fields - and using js will still leave the non-js version of your form not working as you want

Luca
http://www.zen-angel.com

howardfan123
Mar 4th, 2010, 04:37 PM
so a label shows up in my shopping cart in front of the the text box contents

zen-angel
Mar 4th, 2010, 04:41 PM
use the <label> tag for this:



<label for="product3">Last name:</label>
<input type="text" id="product3" name="product3[]" value=""/><br/>


also, when users click on the label text, the relative text field gets the focus

HTH

Luca
http://www.zen-angel.com

howardfan123
Mar 4th, 2010, 04:59 PM
by using the label tag, the label will not post to the cart for some reason.

zen-angel
Mar 4th, 2010, 05:09 PM
that is the expected behaviour! posting labels with the value of a submit is not the best option, what will you do with the data collected? I presume that you will print it somewhere - just add the same label values to your print page.. unless I'm missing the point of having labels submitted with the data collected :)

howardfan123
Mar 4th, 2010, 06:52 PM
The reason for the labels is to make it easier for the customer to read what they are buying in the shopping cart.

met
Mar 4th, 2010, 10:10 PM
i think you are confused

a label is for acessibility purposes, i.e to provide a user friendly short description of what each field on a form represents.

its also used, as mentioned, so when its clicked, the approrpiate field gets focus.

a label has absolutely no effect on what gets posted to the processing script, unless i misunderstand you


so a label shows up in my shopping cart in front of the the text box contents
what does this mean? do you have a live example?

howardfan123
Mar 5th, 2010, 01:12 AM
here is an example

<hr color="#FFFF00"/>
<p><span class="style30">Send directly to recipant:</span><input name="product3[]" type="checkbox" value="{br}{b}SEND CERT DIRECTLY TO RECIPANT---{/b}" onclick="toggle(this, 'shipGroup');"/><br/>
<center><span class="style30">Send to me to give to recipant:</span>
<input name="product3[]" type="checkbox" value="{br}{b}SEND CERT TO ME TO GIVE TO RECIPANT---{/b}" /></center></P>
<input type="hidden" name="price3" value=".00" />
<input type="hidden" name="qty3" value="1" />
<input type="hidden" name="noqty3" value="3" />
<p><div id="shipGroup" align="left">
<span class="style30">First Name</span>
<input type="hidden" name="product3[]" value="{br}FIRST NAME:" />
<input type="text" name="product3[]" value=""/>
<span class="style30">Last Name</span>
<input type="hidden" name="product3[]" value="{br}LAST NAME:" />
<input type="text" name="product3[]" value=""/><br/>
<span class="style30">Address</span>
<input type="hidden" name="product3[]" value="{br}ADDRESS:" />
<input type="text" name="product3[]" value=""/><br/>
<span class="style30">City</span>
<input type="hidden" name="product3[]" value="{br}CITY:" />
<input type="text" name="product3[]" value=""/><br/>
<span class="style30">State</span>
<input type="hidden" name="product3[]" value="{br}STATE:" />
<input type="text" name="product3[]" value="" size="10"/>
<span class="style30">Zip code</span>
<input type="hidden" name="product3[]" value="{br}ZIP CODE:" />
<input type="text" name="product3[]" value="" size="5"/><br/>


here is a sample of the way the cart looks
if the customer chooses to have the cert sent to them to give out they click the other button and i dont want all the address stuff to show up


GIFT CERTIFICATE----,
TO:, john,
FROM:, doe 45.00 45.00
MESSAGE CARD---,
CARD STYLE:, hol-605,
MESSAGE TO SAY:, how are you 1 0.55 0.55

SEND CERT DIRECTLY TO RECIPANT---,
FIRST NAME:, john,
LAST NAME:, doe,
ADDRESS:, xxxx no where street,
CITY:, no where,
STATE:, taxes to hign,
ZIP CODE:, xxxxx, 1 0.00 0.00
All prices are in US Dollars Subtotal 45.55
Shipping 0.00
TOTAL 45.55