RE: [PHP-DB] Form <select> field problem
| From: | Keiran Wynyard | Date: | Tue, 09 Jul 2002 09:20:18 +0000 |
| Subject: | RE: [PHP-DB] Form <select> field problem | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-20417@lists.php.net to get a copy of this message | ||
Beau
Cheers for that. Option one worked as a way of referring to the field. I made a couple of
other 'take-down and rebuilds' but it is now working one hundred percent, and
wouldn't
without your input.
Thanks a whole tonne! :)
Keiran
-----Original Message-----
From: Beau Lebens [mailto:B.Lebens@curtin.edu.au]
Sent: Tuesday, July 09, 2002 2:50 AM
To: 'Keiran Wynyard'; php-db@lists.php.net
Subject: RE: [PHP-DB] Form <select> field problem
Keiran,
A couple possibilities for you;
1. Try referring to the field (in JavaScript) as something like; (might have
to play around with this)
document.existing["groupchoice[]"].selectedIndex
2. Make it so that each selection on the <select> tag is mirrored into
another hidden input field (onSelect=>) and then you actually check the
hidden field for what values are present and what aren't, throwing an error
based on it, rather than on the actual <select>
HTH
Beau
// -----Original Message-----
// From: Keiran Wynyard [mailto:keiran@wynyard.net]
// Sent: Monday, 8 July 2002 5:22 PM
// To: php-db@lists.php.net
// Subject: [PHP-DB] Form <select> field problem
//
//
// Hi
//
// I may be posting this to the wrong place, and if so I
// apologise. If someone knows of a
// better place to post my query please tell me, and I will. :)
//
// This problem is about 50% PHP and 50% Javascript, really to
// do with how the two interface
// with each other.
//
// Anyhoo, down to the problem.
//
// I have a Select form item with 'multiple' set. It sends an
// array of values to be dissected
// and applied to database tables, hence it's name value is
// 'groupchoice[]'. This all works
// well and good when some value(s) are selected, but obviously
// gives an error if the form is
// sent with no value selected. What I need to do is come up
// with an elegant way of stopping
// the form if no entries have been selected (or indeed if all
// entries have been deselected).
// I have successfully used a Javascript function to do this,
// but it only works if the field
// is named 'groupchoice'. The part of the function that is
// causing the problem is listed
// below:
//
// if (!document.existing.groupchoice.selectedIndex != "") //this works
//
// if (!document.existing.groupchoice[].selectedIndex != "")
// //this gives a syntax error
//
// Obviously if I call the field 'groupchoice' the information
// sent is no longer an array,
// and therefore I cannot have multiple selections, which is
// imperative. I have thought of
// other ways of doing the job, such as having an alert pop-up
// if there is an error and then
// return them to the form, as opposed to before the form is
// sent, but didn't feel that this
// was very elegant.
//
// Have any of you PHP gurus out there experienced this kind of
// problem and found a solution?
//
// I would be greatly appreciative if someone would share their
// expertise.
//
// TIA
// Keiran
// keiran@wynyard.net
//
//
//
// --
// PHP Database Mailing List (http://www.php.net/)
// To unsubscribe, visit: http://www.php.net/unsub.php
//