2 parts - Submit Select LABEL - on DYNAMIC form
A bit of a puzzle this one
2 parts
ADDT dynamic form - ie you can edit 1,2,5, 10 at a time.
Form with Select Dropdown for COUNTIES
that inserts the ID into the database rather than the COUNTY NAME
ie 24 inserted into database KENT needs to be posted
I need to POST the COUNTY NAME which is in the Select Dropdown Label
when the MYSQL insert takes place and inserts the ID of the COUNTY into the DB
OK
I can get the Dropdown label by sending this function the Id of a Hidden Form Field I want to POST my value from and the Id of the Dropdown Select I want to get the label from....
<script type="text/javascript">
function disp_text(tg,obj)
{
var targ = document.getElementById(tg);
var el = document.getElementById(obj);
var idx = el.selectedIndex;
var selected_text = el.options[idx].text;
targ.value = selected_text;
}
</script>
AT FORM SUBMIT (A)
onsubmit="disp_text('hid_county','fk_id_cnty_evx_1');"
(note the value of the dynamic form suffix has to be hard coded - problem!)
OR (B), ON DROPDOWN CHANGE
onchange="disp_text('hid_county','fk_id_cnty_evx_<?php echo $cnt1; ?>');return false;"
(note I can use the $cnt1 value here to pick up the dynamic form suffix)
2ND Part
As the form is dynamic I can pick up the counter OK and correctly identify the correct form element (if someone changes the dropdown - B)
Problem - How can I work out the Counter Value of the form elements if they don't touch the select? - but edit 5 forms at a time
Option A - hard wires the _1 to the item name
this will only work when using 1 form
on a multiple insert or update it fails (obviously)
any ideas on how to deal with multiple forms and scenario A?
or is it just simple to force the user to use one form at a time - thats my fallback