Are you a Google Analytics enthusiast?
Share and download Custom Google Analytics Reports, dashboards and advanced segments--for FREE!

www.CustomReportSharing.com
From the folks who brought you High Rankings!
More SEO Content
Set 2 Values With One Form Option
#1
Posted 10 December 2010 - 07:17 PM
Can anyone help me with a suggestion of how I can set 2 field values on an Insert from a single <option value="catid-catname">.
I would like to set catid and catname from the one select option value "catid-catname".
MYSQL Insert:
$ins_products->addColumn("catname", "STRING_TYPE", "POST", "catname");
$ins_products->addColumn("catid", "NUMERIC_TYPE", "POST", "catid");
When I started, I intended and expected to only need the numeric value "catid" but I now need to have "catname" in the table for various functions.
#2
Posted 10 December 2010 - 09:27 PM
So you get back a variable, say $cat_selection, and you extract $cat_id from the first part of the data in the variable and then assign the remaining part to $cat_name. Examples of divider or marker characters include:
/
~
^
&
|
\
*
It's purely arbitrary.
#3
Posted 11 December 2010 - 04:47 AM
The Insert is by a quite complex form which includes asomef pre-populated hidden fields plus user filled in input fields. There are also a number of dropdown select options. Added to a file upload with image resize and the form has a whole lot happening on submit.
So to parse from a Dropdown option into 2 values each into a MYSQL field is very difficult for me to accomplish. In fact I cant worrk out how to Parse and Submit in one action.
One way I see of doing this, is to use an auto submit return form.
The main form would insert and then goto a return page that parsed and updated the 2 fields on auto submit then going to a second return page showing all the product details.
#4
Posted 11 December 2010 - 11:58 AM
#5
Posted 11 December 2010 - 07:11 PM
Within each department, there are between 15 and 20 product categories. I would like a single action (like a dropdown) to select the category.
The categories are sorted to just the 15 to 20 within that department. So as well as all the product specific info, the Category ia assigned by this dropdown. At the point of loading this Add Product form, the Category is still to be selected.
That is why I am trying to enter values in 2 fields (catid + catname) with the single selection. I can either select catid or catname or catid-catname.
Innitialy I thought just assigning the catid would suffice, but an unforeseen requirement now changes that and I need to use both catid and catname.
#6
Posted 12 December 2010 - 07:08 AM
The category ID OR the category name are going to be the same record in the database table and even if the system allows for duplicate category names in different departments, requiring the id AND the name is somewhat superfluous. One or the other plus the deparment id/name should suffice.
Solving the problem is really going to depend on how much you can (or are willing to) rewrite.
1/ Build an javascript associative array and concatenate the values into the select element value attribute using the select element onChange event.
2/ rewrite the code that structures the select element so that it creates the value attribute of the option elements with both the id & name concatenated.
#7
Posted 12 December 2010 - 08:47 AM
Thanks for the flattery Chris, there's no one better than you when it comes to that type of response.
#8
Posted 13 December 2010 - 02:41 PM
What I was envisioning was something like this:
- User sees a form with combined cat-id/cat-name values in a dropdown
- User picks an option from that list
- Your form triggers a script
- Your script parses the form and extracts the data
- INSERT NEW STEP: Parse the dropdown list variable, dividing its contents between two new variables
- ALTERED STEP: Use the new variables from the previous step to do whatever you need to do
#9
Posted 13 December 2010 - 07:43 PM
I have pondered the suggestions in this thread and now have a working solution.
I know I can enter catid_catname as the combined label and use parsing to manipulate every time I need to use the field as a select/sort/anything process. Rather than have this (for me) complication/handicap multiple times forever, I decided to have the 2 separate fields catid and catname.
Anyway, the way I ended up doing this was by entering catid_catname as a temporary value for catname. After creating the record, the return is to an update form which parsed the combined catid_catname and placed the separate values into their own fields. This update form then uses a simple auto-submit script.
Job done.
Probably not as elegant as some solutions could have been, but within my capabilities whereas I was finding the scripting alternatives quite difficult.
Thanks again for the suggestions which helped kick-start my thoughts to solve the problem.
#11
Posted 15 December 2010 - 03:11 PM
Honest man to dishonest man: "Pay no attention to me as I may be lying to you."
Dishonest man to Honest man: "How can you be certain of that?"
#12
Posted 15 December 2010 - 08:32 PM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users









