Forums
This topic is locked
List/Menu help
16 Oct 2007 21:34:06 Rob Lopez posted:
Hi,I have a list/menu that pulls off one table and I need it to return a value for another field in that row. I have no idea how to do this. I can get it to store data for the selection, just not any other fields that are in the same row. Ex. Add User form list/menu selection is Administrator for (usertype), then 9 would be the next value for (userlevel), but it is putting 1 in the database, which is a general user value. Any help would be appreciated. This should be something simple, and I'm sure I will kick myself when I hear the answer.
Replies
Replied 18 Oct 2007 17:20:37
18 Oct 2007 17:20:37 Alan C replied:
Hi,
when you do lists like this there are two values that make up the list, the first is the text or whatever that will actually go into the list that the user will see, the second is the value that will be sent back to the server as data, these are the pairs that you will see in your code, name value pairs.
There's not enough information in your post about exactly what you are doing, but you might need some extra php that gets the appropriate value from the row, let's say you have a record that contains name, phone, sex and you want the dropdown to show names but you want phone to go back to the server when a name is selected, you will have to set up name option pairs for your select html.
You get the same situation where you have two tables that are JOINED - you don't want the actual value, you want the key to the second table, I think it's something like that you are dealing with, sorry if this is a bit vague!
when you do lists like this there are two values that make up the list, the first is the text or whatever that will actually go into the list that the user will see, the second is the value that will be sent back to the server as data, these are the pairs that you will see in your code, name value pairs.
There's not enough information in your post about exactly what you are doing, but you might need some extra php that gets the appropriate value from the row, let's say you have a record that contains name, phone, sex and you want the dropdown to show names but you want phone to go back to the server when a name is selected, you will have to set up name option pairs for your select html.
You get the same situation where you have two tables that are JOINED - you don't want the actual value, you want the key to the second table, I think it's something like that you are dealing with, sorry if this is a bit vague!
Replied 19 Oct 2007 22:28:46
19 Oct 2007 22:28:46 Rob Lopez replied:
Alan, Thanks for the reply. I was aiming toward that angle from the get go, and went into that angle, but was unsuccesful. Until today. For all that have looked at this here is the solution if you are trying to accomplish the same thing:
As Alan mentioned there are 2 values that make up the list. This is what you see in dreamweaver:
<option value="<?php echo $row_table_row['SQLField']?>"><?php echo $row_table_row['SQLField']?></option>
All you change is the first one to represent the field you want written to the database, the second one is for the list:
<option value="<?php echo $row_table_row['DATA_TO_DATABASE']?>"><?php echo $row_table_row['DATA_FOR_LIST']?></option>
I did this, but still didn't work, but that is because you are missing one thing. You have to go to the Server Behaviors window, double click the Insert Record (frm_whatever), then select the field under the Columns window. Then all you have to do is change the value for the column you want to return to the database. Thanks for your help Alan.
Anyone able to help with my cloning a form post?
As Alan mentioned there are 2 values that make up the list. This is what you see in dreamweaver:
<option value="<?php echo $row_table_row['SQLField']?>"><?php echo $row_table_row['SQLField']?></option>
All you change is the first one to represent the field you want written to the database, the second one is for the list:
<option value="<?php echo $row_table_row['DATA_TO_DATABASE']?>"><?php echo $row_table_row['DATA_FOR_LIST']?></option>
I did this, but still didn't work, but that is because you are missing one thing. You have to go to the Server Behaviors window, double click the Insert Record (frm_whatever), then select the field under the Columns window. Then all you have to do is change the value for the column you want to return to the database. Thanks for your help Alan.
Anyone able to help with my cloning a form post?
Replied 20 Oct 2007 13:28:39
20 Oct 2007 13:28:39 Alan C replied:
good to hear it's now sorted out, I'll keep that in mind, I often have to 'experiment' with getting these right, I'm much happier hand coding a lot of things, but it's so much faster in something like DW.