achira
04-18-2012, 05:11 PM
Main question:
Can I use radio buttons on a dynamic form and have the names filled in with the ENUM values of a database column?
A group can only be one type of organization and one size within that organization. So instead of making a separate table to bring these things together, I made one column called "Organization Type" and set it to ENUM with 21 possibilities (7 types, 3 sizes each).
I just started learning PHP a few weeks ago, so please forgive me if this is a question with an obviously simple answer.
Sub question:
If I can use radio buttons, where would I indicate the actual value to be put into the database record?
My initial thoughts are:
do an $orgtype = array( 'value 1', 'value 2', 'value 3'); (php)
create a function that sets the orgtype (js)
add "onClick settype()" to the radio button attributes (html)
is that logical? would it work or am I missing something essential?
ETA (trying to work it out while I hope for a response/feedback):
So far:
//PHP
$orgtype=$_POST['Organization Type'];
//JS sets var based on ENUM values in database
var orgtype=["Large Corporation","Medium Corporation", "Small Corporation"]
I also see that I'd have to use onchange instead of onclick.
Edit again: I found the answer to value question.
Can I use radio buttons on a dynamic form and have the names filled in with the ENUM values of a database column?
A group can only be one type of organization and one size within that organization. So instead of making a separate table to bring these things together, I made one column called "Organization Type" and set it to ENUM with 21 possibilities (7 types, 3 sizes each).
I just started learning PHP a few weeks ago, so please forgive me if this is a question with an obviously simple answer.
Sub question:
If I can use radio buttons, where would I indicate the actual value to be put into the database record?
My initial thoughts are:
do an $orgtype = array( 'value 1', 'value 2', 'value 3'); (php)
create a function that sets the orgtype (js)
add "onClick settype()" to the radio button attributes (html)
is that logical? would it work or am I missing something essential?
ETA (trying to work it out while I hope for a response/feedback):
So far:
//PHP
$orgtype=$_POST['Organization Type'];
//JS sets var based on ENUM values in database
var orgtype=["Large Corporation","Medium Corporation", "Small Corporation"]
I also see that I'd have to use onchange instead of onclick.
Edit again: I found the answer to value question.