I have a form on the index.php page and have session storage enabled. I named all the form fields (id) appropriately.
On a separate page (results.php) I have a form with session storage enabled, the form fields (id) are named the same and it shows the form data perfectly.
However, I would like a drop down value to be the actual text (ie. it displays 1, but should be "Option A")
Same with radio or checkboxes. Instead of a 0 or 1, I would like it to say Yes or No (ie. it displays 0 but should be "Yes")
How do I code the form or edit field to change the result to the text value?
I hope I am explaining this well. Sorry if I am not.
Mike
How do I change the value of a edit field with code?
Forum rules
PLEASE READ THE FORUM RULES BEFORE YOU POST:
viewtopic.php?f=12&t=1901
MUST READ:
http://www.wysiwygwebbuilder.com/forms.html
http://www.wysiwygwebbuilder.com/form_wizard.html
Frequently Asked Questions about Forms
PLEASE READ THE FORUM RULES BEFORE YOU POST:
viewtopic.php?f=12&t=1901
MUST READ:
http://www.wysiwygwebbuilder.com/forms.html
http://www.wysiwygwebbuilder.com/form_wizard.html
Frequently Asked Questions about Forms
-
-
- Posts: 19
- Joined: Thu Nov 06, 2014 6:17 pm
- BaconFries
-
- Posts: 5640
- Joined: Thu Aug 16, 2007 7:32 pm
Re: How do I change the value of a edit field with code?
This can be done with some custom javascript/jquery or with the following Form Conditions and Calculations
-
-
- Posts: 19
- Joined: Thu Nov 06, 2014 6:17 pm
Re: How do I change the value of a edit field with code?
Thank you. I see you can choose javascript on the dropdown. I am used to php, but not javascript as much. How do I reference the form field values in javascript?
The above code breaks the form? Any help is appreciated. Note that I am trying to change a integer value to a string as per the drop down options.
I read the conditions page, but it does not go into changing form field values (from a number to a text string), just calculations and such. A little guidance would be appreciated.
Mike
Code: Select all
if (document.getElementById('age').value = 0) then age.value = "Under 35";
I read the conditions page, but it does not go into changing form field values (from a number to a text string), just calculations and such. A little guidance would be appreciated.
Mike