Community Forums 

Main Content

Re:How to setup dropbox?

    Aug 09 2009 15:31:28

    #1

    Veganline

    Join date : 2008-10-09      Posts : 9

    When the form has been going for a few months and you're used to it, there's a script that stops people ordering the default option:
    http://techkey.site88.net/validation/
    view source for code


    For testing, the javascript itself is in the header, but you could find on the net how to put it in a separate text tile that's referred to from each page.

    I'm no expert on this and had to pay someone to write it, but the script is
    <script type="text/javascript">
    //<![CDATA[
    function test(obj){
    var sel=obj.getElementsByTagName('select')[0];
    var ix=sel.selectedIndex;
    var txt=sel.options[ix].text;
    if((ix==0)||(txt=='')){
    alert('Please make a selection');
    return false;
    }else{
    return true;
    }
    }
    //]]>
    </script>

    ...and the crucial bit is
    if((ix==0)||(txt=='')){
    alert('Please make a selection');
    which means that if the selected option is the default one, whether you've called it 0 or not, or if the selected option is blank, then a grey alert box pops up to say "please make a selection"

    This is all probably a distraction when writing the first drop-down form, but good to come back to a few months later.