a form that selects data and/or adds to menu choices

I want to design a form

there are two form input elements

option select

and

textbox





------------------
if user enters data into textbox
then
do not use option select
add to option select menu choices
mysql insert into categories column


else if user choses option select
use option select menu choice

------


sample data:

categories option select:
electronics
silverwear
bedding

textbox:
user enters new category: keyboards


now option select:
electronics
silverwear
bedding
keyboards
LVL 1
rgb192Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ahmed MerghaniSoftware EngineerCommented:
Hello,

Your PHP code will be something like this:

if($_POST['text_input']  != ""){
     //code to insert the new category option in the database
}else if($_POST['option_select']  != ""){
    //use the selected option menu
}
0
Jagadishwor DulalSenior Web DeveloperCommented:
I think you want some thing like the example below, Hope you will manage php and database codes :

<html>
<head>
<title> Test</title>
<script src="http://code.jquery.com/jquery-1.4.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(window).load(function(){
var $category = $('#category'),
$newcategory = $('#newcategory');
$category.change(function() {
if ($category.val() == 'other') {
$newcategory.removeAttr('disabled');
} else {
$newcategory.attr('disabled', 'disabled').val('');
}
}).trigger('change'); 
});
</script>
</head>
<body>
<label>Select Category</label>
<select id="category" class="category" name="category">
<option value="electronics">Electronics</option>
<option value="silverwear">Silverwear</option>
<option value="bedding">Bedding</option>
<option value="other">Other</option>
</select><br/>
<label>Enter New Category</label><input id="newcategory" class="text" type="text" name="newcategory" disabled="">
</body>
</html>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rgb192Author Commented:
works great

only lets user enter text data when dropdown is chosen

thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.