Author |
Message |
ThePiston
Worker


Joined: Dec 22, 2004
Posts: 135
|
Posted:
Mon Oct 17, 2005 10:28 pm |
|
I have a form that uses radio inputs to get a result. This is the code for the relevant part of the formCode: ."<input type=\"radio\" name=\"locationid\" value=\"1\" $sel1> "._FW."<br>"
."<input type=\"radio\" name=\"locationid\" value=\"2\" $sel1> "._NW." <br>"
."<input type=\"radio\" name=\"locationid\" value=\"3\" $sel1> "._N." <br>"
."<input type=\"radio\" name=\"locationid\" value=\"4\" $sel1> "._S." <br>"
."<input type=\"radio\" name=\"locationid\" value=\"5\" $sel1> "._E." <br>"
."<input type=\"radio\" name=\"locationid\" value=\"6\" $sel1> "._CH." <br>"
."<input type=\"radio\" name=\"locationid\" value=\"7\" $sel1> "._RF." <br>";
| What I'd like to do is have each input submit 2 values for 2 different variables. So, if the first radio button was checked, then a value of '1' would be placed for the 'locationcode', but I'd also like a value of "Far West End" to be placed in the 'description' variable inside same table. Could I do something like this? Code:if ($locationid == '1') {
$description = 'Far West End';
}
| then in the query do thisCode:$query = "insert into table (locationid, description) values ($locationid, $description)";
|
|
|
|
|
 |
Raven
Site Admin/Owner

Joined: Aug 27, 2002
Posts: 17088
|
Posted:
Mon Oct 17, 2005 11:03 pm |
|
Absolutely. Another way would be something like thisCode:."<input type=\"radio\" name=\"locationid\" value=\"1/Far West End\" $sel1> "._FW."<br>"
|
Then instead of the if test logic, you could do thisCode:$locArray = explode('/',$locationid);
$locationid = $locArray[0];
$description = $locArray[1];
$query = "insert into table (locationid, description) values ($locationid, $description)";
|
or even simplerCode:$locArray = explode('/',$locationid);
$query = "insert into table (locationid, description) values ($locArray[0], $locArray[1])";
|
|
|
|
|
 |
ThePiston

|
Posted:
Tue Oct 18, 2005 8:42 am |
|
so this codeCode:$locArray = explode('/',$locationid);
$query = "insert into table (locationid, description) values ($locArray[0], $locArray[1])";
| goes into the form or the "saveoffice" code? I know I need to add $description to globals, etc too. Also, would I need to change this code:Code: case 'saveoffice':
saveoffice($locationid, $description, $offname, $add1, $add2, $city, $state, $zip, $phone, $fax, $website);
break;
| to this:Code: case 'saveoffice':
saveoffice($locarray[0], $locarray[1], $offname, $add1, $add2, $city, $state, $zip, $phone, $fax, $website);
break;
| ? |
Last edited by ThePiston on Tue Oct 18, 2005 8:51 am; edited 1 time in total |
|
|
 |
Raven

|
Posted:
Tue Oct 18, 2005 8:46 am |
|
It goes wherever you actually run the query from. $description does not have to be global, necessarily, since you are passing it via a function call. |
|
|
|
 |
ThePiston

|
Posted:
Tue Oct 18, 2005 9:14 am |
|
Raven wrote: | It goes wherever you actually run the query from. $description does not have to be global, necessarily, since you are passing it via a function call. | Do I have to chaneg the "case saveoffice" code to thisCode: case 'saveoffice':
saveoffice($locarray[0], $locarray[1], $offname, $add1, $add2, $city, $state, $zip, $phone, $fax, $website);
break;
|
? |
|
|
|
 |
ThePiston

|
Posted:
Tue Oct 18, 2005 9:47 am |
|
nm, got it, thanks again Raven, you rule |
|
|
|
 |
|