By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,568 Members | 1,194 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,568 IT Pros & Developers. It's quick & easy.

on submit, select all

P: n/a
Ike
I have a form I am Posting. On that form, I have a selection list,
selectedList....wherein I want to make all the items that are within that
lest be selected, automatically, when the submit button is hit.

Is there a way to do this? Thanks, Ike
Jul 20 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
In article <kk*******************@newsread3.news.atl.earthlin k.net>,
rx*@hotmail.com enlightened us with...
I have a form I am Posting. On that form, I have a selection list,
selectedList....wherein I want to make all the items that are within that
lest be selected, automatically, when the submit button is hit.

Is there a way to do this? Thanks, Ike


Um, why?
Rather defeats the purpose.

Can you do it? Yeah. Should you? Probably not. You probably want another
type of control.

--
--
~kaeli~
Condoms should be used on every conceivable occasion.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #2

P: n/a
Lee
Ike said:

I have a form I am Posting. On that form, I have a selection list,
selectedList....wherein I want to make all the items that are within that
lest be selected, automatically, when the submit button is hit.

Is there a way to do this? Thanks, Ike


Yes, provided that you also allow the user to select as many
items as they like, but it's a bad idea. It means that your
server-side code won't receive data that it needs if the user
has disabled JavaScript.

List all of the available options in a hidden form field or
hard-code them into the server-side script, or write them down
and tape the list to your monitor, depending on how you're
processing the form data.

Jul 20 '05 #3

P: n/a
Ike
Its a drag and drop control. Elements are dragged into or out of it. I want
to select it all before submit is hit.

Thanks for the advice on condoms too, I never thought of that. Ike

"kaeli" <ti******@NOSPAM.comcast.net> wrote in message
news:MP***********************@nntp.lucent.com...
In article <kk*******************@newsread3.news.atl.earthlin k.net>,
rx*@hotmail.com enlightened us with...
I have a form I am Posting. On that form, I have a selection list,
selectedList....wherein I want to make all the items that are within that lest be selected, automatically, when the submit button is hit.

Is there a way to do this? Thanks, Ike


Um, why?
Rather defeats the purpose.

Can you do it? Yeah. Should you? Probably not. You probably want another
type of control.

--
--
~kaeli~
Condoms should be used on every conceivable occasion.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #4

P: n/a
"Ike" <rx*@hotmail.com> wrote in message
news:kk*******************@newsread3.news.atl.eart hlink.net...
I have a form I am Posting. On that form, I have a selection list,
selectedList....wherein I want to make all the items that are within that
lest be selected, automatically, when the submit button is hit.

Is there a way to do this? Thanks, Ike

Perhaps this?
<html>
<head>
<title>selected.htm</title>
<script language="javascript" type="text/javascript">
<!--
function selectList() {
var form = document.forms[0];
for (var i=0; i<form.selectedList.length; i++) {
form.selectedList.options[i].selected = true;
}
return false;
}
// -->
</script>
</head>
<body>
<form method="post" onsubmit="return selectList()">
<b>Numbers:</b>
<br>
<select name="selectedList" multiple size="4">
<option value="1">One
<option value="2">Two
<option value="3">Three
<option value="4">Four
</select>
<br><input type="submit" value="Submit">
<br><input type="reset" value="Clear">
</form>
</body>
</html>
1) Change "return false;" to "return true;" after testing.
2) Change or remove: size="4"
Jul 20 '05 #5

P: n/a
In article <H1******************@newsread3.news.atl.earthlink .net>,
rx*@hotmail.com enlightened us with...
Its a drag and drop control. Elements are dragged into or out of it. I want
to select it all before submit is hit.


Well, assuming the user has javascript enabled, which I assume they must
for the drag and drop to work, you can just make it a mutli-select and
then iterate through the options and set selected to true for each one.
You cannot do this before submit is hit - you do it in the onClick of
the submit button, before the event is propagated to the onSubmit
handler.

See McKirahan's reply.

--
--
~kaeli~
The more ridiculous a belief system, the higher probability
of its success.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #6

P: n/a

"Ike" <rx*@hotmail.com> schreef in bericht
news:kk*******************@newsread3.news.atl.eart hlink.net...
I have a form I am Posting. On that form, I have a selection list,
selectedList....wherein I want to make all the items that are within that
lest be selected, automatically, when the submit button is hit.

Is there a way to do this? Thanks, Ike


ok..
put this in the head:

</script>
function selectAll(row)
{
for (i = 0; i<row.options.length;i++)
{
row.options[i].selected=true;
}
}
</script>

and this in the submit button

<input type=submit.....onClick="selectAll(this.form.selec tedList)">

that should do the trick (also)
Jul 20 '05 #7

P: n/a
Ike
Oh yes....Iwas tring to do it onsubmit=...but s/b onClick=.... ty

"kaeli" <ti******@NOSPAM.comcast.net> wrote in message
news:MP************************@nntp.lucent.com...
In article <H1******************@newsread3.news.atl.earthlink .net>,
rx*@hotmail.com enlightened us with...
Its a drag and drop control. Elements are dragged into or out of it. I want to select it all before submit is hit.


Well, assuming the user has javascript enabled, which I assume they must
for the drag and drop to work, you can just make it a mutli-select and
then iterate through the options and set selected to true for each one.
You cannot do this before submit is hit - you do it in the onClick of
the submit button, before the event is propagated to the onSubmit
handler.

See McKirahan's reply.

--
--
~kaeli~
The more ridiculous a belief system, the higher probability
of its success.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.