Web Hosting Talk







View Full Version : Help with HTML forms


mantra
09-06-2008, 04:16 PM
I have a HTML form that has a menu/select field with some options:

<select name="Room Type" id="Room Type" onChange="KW_calcForm('total',1,-1,'#Reg Type','+','(','#No of Rooms','*','#Room Type',')','*','#No of Nights')">
<option value="0"> </option>
<option value="75.00001">Ocean Front Double Bed - $75</option>
<option value="75.00002">Ocean Front King - $75</option>
<option value="75.00003">Ocean Front King Jr. Suite - $75</option>
> <option value="155">2 Bedroom Exec Suite - $155</option>
<option value="165">3 Bedroom Exec Suite - $165</option>
</select>

So for example, if the user selects Ocean Front King - $75, the value is $75.

However, the value that gets saved into my database is 75, and not 'Ocean Front King - $75' ...

Is there anyway to save the Item Label instead of the value ???

Or any workaround?

SolidTools
09-06-2008, 05:01 PM
Check your database field, is it decimal or varchar?

mantra
09-06-2008, 05:08 PM
Check your database field, is it decimal or varchar?

varchar, why does that make a difference?
the html form saves the 'input value', but i want to save the 'item label'

SolidTools
09-06-2008, 05:55 PM
Sorry, I misunderstood. I think the $ sign is striped by PHP. are you using PHP?

SolidTools
09-06-2008, 06:01 PM
Try to replace the "$" with "& # 3 6;" (remove the space)

I'm sure there is a better solution, but I'm not good with PHP.

mantra
09-06-2008, 06:29 PM
in my example, my values are 75.00001, 75.00002, etc. etc.

this is what gets saved to the database, but I'd rather have the text that goes along with it get saved instead

Ocean Front Double Bed - $75

The values are numbers because I am doing some form calculation also.

thanks

qualityhosts
09-06-2008, 06:49 PM
the form will post the values and not the text that goes along with it, you can use some javascript to change the values to the text you want? You need to find a way to put the text as the value if not part of the value or maybe post the text as a hidden field or something.

bear
09-06-2008, 07:11 PM
Is there anyway to save the Item Label instead of the value ?

Whatever is in the value field is what will be passed by the script/form, so pass that info, IE:

Not
<option value="75.00001">Ocean Front Double Bed - $75</option>
But instead:
<option value="Ocean Front Double Bed - $75">Ocean Front Double Bed - $75</option>

The values are numbers because I am doing some form calculation also.

An alternative would be to catch the numeric value with PHP, and use that to rewrite the value that gets stored, after you perform your calculations.

mantra
09-06-2008, 07:16 PM
can someone assist with whatever they are recommending?