![]() |
| ||
| how to populate a cfselect box depending upon the selection on raido button Hi I am new to coldfusion.I dont know much about cold fusion.I have a problem like there are two radio buttons and a select box.Depending upon the slection of the radio button the select box should be populated.i.e if first radio button is selected then select box should populate some set of values and if second radio button is slected then selct box should be populated with other set of values Thanks in Advance |
| ||
| Re: how to populate a cfselect box depending upon the selection on raido button You have to do a few different things. First ColdFusion being a Server Side Programming language, there is no way to do what you want using ColdFusion directly. You will have to use Javascript to dynamically link the drop down menus to an array that is populated by ColdFusion. Another way to do it would be to have CF populate both dropdown menus and use javascript to control which is visible (using CSS) depending on which radio button you select. I hope this puts you in the right direction. |
| ||
| Re: how to populate a cfselect box depending upon the selection on raido button Thanks for the reply can you give me some example using code....... |
| ||
| Re: how to populate a cfselect box depending upon the selection on raido button Like I said there are a few different ways to do this. The following is what put together for you. Put the following in the document head: <cfquery datasource="yourDatasource" name="menu1"> The above code does a few things. First it gets the data for the drop down menus by polling your database. If the data for these two menus are in the same table (which would make sense) you will need to include a WHERE clause in the above queries. These values are put into two drop down menus that appear or disappear depending on which radio button is checked. The following code will be found in the document body: <form action="" method="post"> I hope this helps. |
| ||
| Re: how to populate a cfselect box depending upon the selection on raido button Thank u very much.....it solved my problem,.,,,,,,,now i have another problem .... I am displaying a dynamic table which consits of four columns named as Ingredient,Lot,d_amount,d_unit......out of which Ingredient,d_amount,d_unit are taken from one query named as "qrecipes" i.e from one table and Lot Cloumn is taken from another table.Now the problem is the data that is to be displayed in lot column is dependent on the data present in ingredient.i.e If the first row ingredient column has "XYZ" then i need to pick the id of "XYZ" from second table and display in lot column. Ingredient Lot d_amount d_unit 1 xyx 345 is id for XYZ which should be displayed from Second table Below is my code ....please say what is wrong .....please suggest me if there are any other methods or any kind of solution to solve this problem Queirs <cfquery name="qrecipes" datasource="testmsexcell"> Table table border="2px" id="maketable"> |
| ||
| Re: how to populate a cfselect box depending upon the selection on raido button Can you not just join the two tables using an inner join? I suspect you can do what you need with one query, but I have to know more about your table design with the primary and foreign keys. |
| ||
| Re: how to populate a cfselect box depending upon the selection on raido button Please neglete those dots.i have kept those for displaying tables properly First Table is Recipes Product...........ingredient.........d_amount.......... d_unit id abc................xyz...............78................... lb..... ....................uvw........................................... efg..................hig ......................lkm In the first table the id is the primarykey which is autoincremented. Second Table is Lot:The id is primarykey which is not related to first table which is recipes. id.............ingredient 5t6y.............xyz 7yh8.............xyz 9jnu.............uvw Now i am trying to diaplay to user something like this by taking product as input from the user.if the user selects product as "abc" ingredient........lotids............d_amount.......d_unit xyz...............5t6y ...................7yh8 uvw.................9jnu I am able to display the ingredient,d_amount,d_unit correctly but i am unable to display the correct lotids for the repective ingredient.I am using CFSELECT tag to display the lotids |
| ||
| Re: how to populate a cfselect box depending upon the selection on raido button Let me re-phrase what you are saying to see if I get it. You have a table called recipes and a table called lots. These two tables are linked by ingredients. What you want is the user to be able to select a product and get from the database what the lot id is for the ingredient(s) that goes into the recipe. This should be a pretty simple inner join. Try the following query (making changes to the column names as needed): SELECT * If that works, let me know and I can get you the rest of the way. |
| ||
| Re: how to populate a cfselect box depending upon the selection on raido button Thanks the given sql is working ...it gave me correct data ..but now the problem is that it is displaying same data multipile times.i.e ingredient........lotids............d_amount.......d_unit xyz...............5t6y xyz................7yh8 xyz................98uj uvw.................9jnu instead of that i need to display it as xyz...............5t6y ..................7yh8 ...................98uj uvw.................9jnu |
| ||
| Re: how to populate a cfselect box depending upon the selection on raido button 2 Attachment(s) Humm... Maybe I do not understand what you are trying to do, because if you have two products with the same ingredient you will get duplication of that ingredient. I am not sure that is avoidable, however you should not be getting different lot_ids. I am having trouble understanding your example tables. So I attached a screen shot of what I put together and maybe you can tell me what I am doing differently. |
| All times are GMT -4. The time now is 6:35 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC