PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
this seems like a very easy question...but is it possible to have a drop down list where besides selecting values from the list, user can also enter other values...which will then be stored in a database?
Burrito wrote:sure, mean a text box where people can enter a "new" value do you? Have that new value added to the select box for future selections you want?
be done using a combination of JS (if want it on the same page load you do), and php this can be.
if interested in some code you are, let me know you should and some code I will post.
I am intrested to know. Please post the js Burrito Thankssss
<!DOCTYPE HTML PUBLIC "e;-//W3C//DTD HTML 4.01 Transitional//EN"e;>
<html>
<head>
<title>Untitled</title>
<script>
function addNew(what){
var nOption = document.createElement("e;OPTION"e;);
document.MyForm.MySelect.options.add(nOption);
nOption.innerHTML = what;
nOption.Value = what;
}
</script>
</head>
<body>
<form name="e;MyForm"e;>
<select name="e;MySelect"e;>
<option value="e;Burrito"e;>Burrito</option>
</select><br>
<input type="e;text"e; name="e;newOption"e; onBlur="e;addNew(this.value)"e;>
</form>
</body>
</html>
that will add the new option on blur of the text box. If I were the one doing this, I would also add some xmlhttp (yes I know, I'm beating this like a dead horse...but it's sooo good) to update the database so on a page refresh, the new option comes down from the database.
this only "works" in firefox and it needs a lot of tweaking to make it work better. for example the text field size grows waaay too big on some values entered in..try entering "bling bling" and it grows to about the right size. Then try "123" and it grows way too big. It's a start though and can hopefully get you moving in the right direction if you must have the text field directly on the "select" a true "combo" box.
A combobox is just a combination of selectbox and inputbox where users can either select from options or enter other value (ei. not to add it as new option)