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:[EMAIL PROTECTED]] // Sent: Monday, 8 July 2002 5:22 PM // To: [EMAIL PROTECTED] // 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 // [EMAIL PROTECTED] // // // // -- // PHP Database Mailing List (http://www.php.net/) // To unsubscribe, visit: http://www.php.net/unsub.php // -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php