views:

20

answers:

1

I'm learning so be nice.

I'm developing a web app for a product management system. My office purchase wholesale from multiple vendors and direct.

My web app needs to accommodated basic "new vendor" creation within a product insert/update form.

Is there a simple way to have an option in my combo box "New Vendor" that opens an input box for entering the name, adding it to the list? I will have additional areas to edit the vendor info, but I need to allow for quick-add within my form.

Suggestions? Directions? Comments? "Any help is good help, unless it's not help."

Thanks

-jt

A: 

So, I did some more research and I was just wording my question wrong. Here's what I got to work:

Script

<script type="text/javascript">
<!--
function message(value){
    if(value=="newVendor"){// New Vendor is selected
        var vendor = prompt("Vandor's Name","");

        var elementSelect = document.getElementById('vendor');

        try{
        elementSelect.add(new Option(vendor, vendor), elementSelect.options[2])
        }
        catch(ex){
        elementSelect.add(new Option(vendor, vendor), 2)
        }
    }
}
//-->
</script>

HTML

<div>
    <form>
        <select id="vendor" name="vendor" onChange="message(this.value);">
            <option value="scp">SCP</option>
            <option value="keller">Keller</option>
            <option value="newVendor">New Vendor</option>
        </select>
    </form>
</div>

Any comments would be helpful.

-jt

taylorjes
Didn't mean to answer my own question... Just found a solution and wanted to share.
taylorjes