Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    Jun 2003
    Posts
    183
    Thanks
    0
    Thanked 0 Times in 0 Posts

    edit combo like browser combo

    hi,
    anybody knows how to get combo box exactly like in browser,so that i can enter my own text in select or i can also delete and in the same time it also adds up exactly like internet explorer we can add edit delete or select
    <select name="Sites">
    <option value="yahoo">yahoo</option>
    <option value="google">google</option>
    <option value="msn">msn</option>
    <option value="times">times</option>
    </select>

    this will only show but i cant add delete by own

    anybody having any script i will be grateful

    thanks in advance

  • #2
    Regular Coder
    Join Date
    Aug 2002
    Location
    São Paulo, Brazil
    Posts
    367
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Have a look at this.
    /Daniel

  • #3
    Regular Coder
    Join Date
    Jun 2003
    Posts
    183
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i no this site but i want soemthing like adress browser where we can type in anythign and then it will added up as well as we can delete by pressing backspace or delete from keyboard

    thanks in advance

  • #4
    Regular Coder
    Join Date
    Jun 2003
    Posts
    183
    Thanks
    0
    Thanked 0 Times in 0 Posts
    lot of bugs in this site always i have to click on button to get the value of new item

    any simple java script will really be appreciable

    im wrote one script but i want to have adress bar browser not like buttons to add and delete

    <HTML>
    <HEAD>
    <TITLE>Document Title</TITLE>
    </HEAD>
    <BODY>
    <SCRIPT>

    function add2() {
    var newitem=document.form.t1.value;
    document.form.list[document.form.list.length] = new Option(newitem, document.form.list.length);
    }

    function del() {
    if (document.form.list.selectedIndex >= 0) {
    document.form.list.options[document.form.list.selectedIndex]=null;
    document.form.list.selectedIndex=0;
    }
    }
    </SCRIPT>


    <h1>Adding/Deleting List Items</h1>
    <center>
    <FORM name=form>
    <table border=0><tr><td align=right>
    <input type=text name=t1 size=7><BR>
    <SELECT name=list size=6>
    <OPTION>Item 1
    <OPTION>Item 2
    <OPTION>Item 3
    <OPTION>Item 4
    </SELECT>
    </td><td valign=top><INPUT type=button value=Add onclick=add2()></td></tr>
    </tr><td></td><td><INPUT onclick=del() type=button value=Del>
    </td></tr></table>
    </FORM></CENTER>
    </BODY>
    </HTML>


    thanks in advace for modify this script

  • #5
    Regular Coder
    Join Date
    Aug 2002
    Location
    São Paulo, Brazil
    Posts
    367
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I thought you wanted a dropdown...

    You can add and delete items using the keydown-event:
    Code:
    <HTML>
    <HEAD>
    <TITLE>Document Title</TITLE>
    </HEAD>
    <BODY>
    <SCRIPT>
    
    function getKey() {
        return (document.all ? event.keyCode : -1);// Add NS support
    }
    
    
    function add() {
        var newitem=document.form.t1.value;
        document.form.list[document.form.list.length] = new Option(newitem, document.form.list.length);
    }
    
    function del() {
        if (document.form.list.selectedIndex >= 0) {
            document.form.list.options[document.form.list.selectedIndex]=null;
            document.form.list.selectedIndex=0;
        }
    }
    </SCRIPT>
    
    
    <h1>Adding/Deleting List Items</h1>
    <center>
    <FORM name=form onSubmit="return false;">
    <input type=text name=t1 size=7 onkeydown="if(getKey()==13){add();this.value='';}"><BR>
    <SELECT name=list size=6 onkeydown="if(getKey()==46){del();}">
    <OPTION>Item 1
    <OPTION>Item 2
    <OPTION>Item 3
    <OPTION>Item 4
    </SELECT>
    </FORM>
    </CENTER>
    </BODY>
    </HTML>

    This is for IE only and I have no idea how to use this on NS and Mozilla, but I'm sure you can find it searching the forum.
    /Daniel

  • #6
    Regular Coder
    Join Date
    Jun 2003
    Posts
    183
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hi,

    thanks but i need drop down exactly like como box where i can add there and delete same like adress bar in browser and i dont want this <input type=text>

    thanks for understanding

  • #7
    Regular Coder
    Join Date
    Aug 2002
    Location
    São Paulo, Brazil
    Posts
    367
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I don't think that's possible using a <select> alone. You probably have to build your own control, like using the code above with the list inside a floating div which you hide/show.
    Or try to use the one I linked to above.
    /Daniel


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •