简体   繁体   中英

Form select button to insert info to db mysql

I need help here.. I want to create some form for submit data to db. I have no problem with the form and inserting data to db. but I stuck when I want to add new value to db table column. I have create 1 select button and on the select button value list from db column (eg category). picture attached.

Top: select the value from db and input disable

bottom: select create new and input enable to create new value

Sorry stackoverflow does not allow me to attach img. Here is the link

http://dl.dropbox.com/u/121852/form-elements.jpg

Hope you guys are clear and can help me.. thanks in advance!

If I'm getting you correctly - you want an final option on the select's options list with "create new one"?
Than you should give it a unique value like "createcategory" and put onchange event on that select box

<select name="..." onchange="javascript:checkSelect(this.value);">

As you can see - I called the javascript function checkSelect that you should create with somethis like that:

function checkSelect(val)
{
    if(val == "createcategory")
        document.getElementById('the_input_id').disabled = false;
    else
        document.getElementById('the_input_id').disabled = true;
}

What I did in this function is to check on every change of the select-box if the value of the selected option is "createcategory", and if so - I'm setting the text input disabled to false, so it would work, otherwise - I'm setting it again to true

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM