I have a need to force all items in a listbox to become selected before I force a submit.

I need something to select everything in a listbox called SpacesServed:

$("#form1").submit( function() { . . . code goes here . . . } );

Any ideas?

is this what you are looking for?

<script type="javascript" >
//replace formname with with the name of your form and inputname with the 
//name of the input field you want to select
document.formname.inputname.focus(); 
  document.formname.inputname.select(); 
</script>

Actually, no.

The code I ended up needing/using was more like this:

$("#Formname").submit( function() {
        $('#listbox2').attr('selected','true');
    }); 

Thanks though.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.