What I want to do now is to replace this with the appropriate code so instead of taking the values from this "hard coded" list is to take the values from a table (already set up and only has 1 field "flocknumbers") which contains the values.
I'll give that a try later and let you know. I think I can strip some line out as I should already be connected to the db/host and I know there will be results.
If I unedrstand you correctly you are wanting a select list where the user can add a value on-the-fly by typing it in to the select list. That is not possible with any HTML technology.
Well, not without a LOT of work-arounds. There was a javascript I saw one that combined a select list and a text field to give that functionality - but it cost money.
Here is a possible solution. 1) Create a text box with the name that the select list has now and change the select list name to something else. The page receiving the form will get the value from the text box. Then use an onchange event on the select list and use it to populate the text box. Then add an option to the end of the selefct list for "Other".
When the user selects any value except other, the value is populated into the text field and the text field is hidden. When the user selects "Other" the field is emptied and becomes visible.
<form name="test"> Flock No: <select name="flock_no_select" onchange="setFlockNo(this.value)"> <option value="Option A from DB">Option A from DB</option> <option value="Option B from DB">Option B from DB</option> <option value="Option C from DB">Option C from DB</option> <option value="">Other</option> </select>
I thought it would be a bit awkward - if not impossible. I'll keep a copy of the code you've supplied and look at it at a later date as I'm just beginning to learn the basics of PHP/MySQL at the moment.
Hi, me again (struggling as usual), I have another...
I've created this to extract data from a table and display all in a dropdown box. I want to use this to only add the selected "id" into a field named "parent_id"
So, which bit do I have to change ?
Many thanks.
<?php
$query = "SELECT id, petname, flock_no, ind_no FROM flock ORDER BY petname";
$result = mysql_query($query) or die(mysql_error());
First of all, you should make new posts for new issues.
As to the code above and your query, I do not understand.
If you have a select field with the IDs why do you need to populate the selected ID into another field? Also your select field and option statements above has a very malformed name. What are you trying to accomplish by having comma separated values as the name/values? If it works at all it will only recognise the first value for each.
The information on Computing.Net is the opinions of its users. Such
opinions may not be accurate and they are to be used at your own risk.
Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE