This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Dreamweaver > March 2005 > Re: javascript form question





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Re: javascript form question
Robert E Boughner

2005-03-10, 11:17 pm

middletree wrote:
> I saved an asp page as html and put it up there at
> http://www.middletree.net/addtoticket.htm. I tell you that because you'll
> encounter a js error when you load that page, and it is only because I
> rushed to get it up there.
>
> My question has to do with the multiple list box at the bottom. When the
> page loads, it pre-loads in the box on the right, all the employees who are
> associated with this ticket. The box on the left actually contains all 178
> employees. I took them out for this thing, because I didn't want to publish
> a bunch of names of people so that Lord-knows-who can read it here.
>
> Anyway, the name(s) in the right box only get saved to the database if they
> are highlighted when the page is submitted. For some reason, the names are
> un-highlighted when the page loads. I can ask all users to make srue it gets
> highlighted before they submit, but it isn't realistic to expect 100% of
> them to remember to do that 100% of the time.
>
> Is there some JS code which will make sure that when the submit (Add this
> info) button is clicked, all names in the box on the right will become
> selected, whether they were or not?
>
>


you can use a code like this:

function selectAll(ElementName) {
var obj=document.forms[0].elements[ElementName];
for (var i=0; i<obj.options.length; i++) obj.options[i].selected=true
}

Where ElementName is the name of your select box (a string value) and
assuming that there is only one form on the page. If there are more
than one then change the second line to
var obj=docment.forms['formName'].elements[ElementName];

That should work for you if I haven't done anything stupid.

Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews