Page 1 of 1
Multi Selection Valiation
Posted: Fri May 04, 2007 10:36 pm
by dharprog
Hi
I'm using a multiple selection box. But my problem is how to validate that is selected or not? i"m unable to find out the solution for this.
If anybody come across to this please tell me.
Thank You very much.
Posted: Fri May 04, 2007 10:37 pm
by John Cartwright
You validate your select box like any other input..
Post what your trying to do, maybe it will shed some light on what your having difficulties with.
Posted: Mon May 07, 2007 3:32 am
by CoderGoblin
Selection/combo boxes will default to the first item if nothing else is selected. Normally the first item is delibrately something like below
Code: Select all
<select name="mysel">
<option value="0">Please Select....</option>
<option value="1">Option1</option>
<option value="2">Option2</option>
<option value="3">Option3</option>
</select>
Using the above HTML, by default the $_POST['mysel'] or $_GET['mysel'] (depends on the form) will return the first option value (in this case 0) if the user doesn't do anything. You can then use (
empty to test if the user has a value.
Hope that is what you meant.
Hi Here is the code
Posted: Mon May 07, 2007 11:48 am
by dharprog
Hi
NOt that one.
The code is like this
<select name="skillset[]" class="ccpsComboBox" multiple="multiple">
<? $str = get_table("categories"); while($row = mysql_fetch_array($str)){ ?>
<option value="<?=$row[cat_name]?>"><?=$row[cat_name]?></option>
<? }?>
</select>
You can test this one so that you could understand. I'm not getting the validation for this multiple selection.
Thank you very much.
Posted: Mon May 07, 2007 2:38 pm
by pickle
Check
& please use [syntax ][/syntax ] tags to highlight your code.
Hi
Posted: Tue May 08, 2007 7:15 am
by dharprog
Hi Pickle,
Fine thank you for the information but i'm asking how to validate that in javascript in the client side itself. Not in php.
Thank YOU.
Posted: Tue May 08, 2007 9:42 am
by pickle
Boy you sure did ask for Javascript. Man I was off yesterday!
Javascript could work like this, but it's untested:
Code: Select all
if(document.getElementById('idOfElement').value)
{
...
}
That'll just check if the value exists - you might want to do something more complex & thorough.