| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read | ![]() |
|
||||||
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Ok, this is not really a php question, but I could not find any javascript forums so........Basically I've been doing an online survey. And I'm using javascript to validate form input. I'm aware of how to check radios and dropdowns and thats all fine....My problem is for one question I want the user to pick a few answers from a wide selection of dropdowns, but not force them to pick all of them.
this is my usual script if ( document.form1.e46.selectedIndex == 0 ) { alert ( "Please answer all questions before continuing!" ) return(false); } But obviously if I use that for all the dropdowns then they will have to answer all of them. I need to get them to answer at least one dropdown basically, then they can continue....Any of you kind folks know a bit of java? |
|
|||
|
Umm js isn't my forte but couldn't you use some kind of population method?
javascript.internet.com/forms/dropdown-box-population.html I use spry for validation where it writes the js for me. I also use php to validate certain criteria
__________________
West Dorset Community |
|
|||
|
What is spry? Yeah I've looked at the link you provided. Its not quite what I'm after. thats the problem if you have not learned javascript. You can't just throw it together and hope it works. Because you've got no idea how to write it...
|
|
|||
|
Spry is a set of js libraries already built and easy to implement.
labs.adobe.com/technologies/spry Am sure there are folk on here good at js so you will probably get an answer sooner or later.......... As mentioned, you could use php. If it were a few dropdown menus and only one need to be filled in then you would create an array of dropdowns, then check if that array is empty or not. But js maybe your prefered option
__________________
West Dorset Community |
|
|||
|
Both are equally perplexing to a noob like me unfortunately... Basically the problem is that there are mutiple product categories, and below each product are 8 dropdowns which rate a function of the product (so 5 columns each with 8 dropdowns below). So I have to force the user to choose at least one drop down, then continue to fill in all the 8 categories for that product. But not all products. Only those that apply... So I dont have one exact dropdown I can validate. They have a choice. I found this code
var sel = document.forms[0].elements["selectName"]; var fld = document.forms[0].elements["textboxName"]; if(sel.selectedIndex == 1 && /^\s*$/.test(fld.value)) { alert("Comments required when option 2 selected."); fld.select(); fld.focus(); return false; } I think I may be looking at something similar...Basically if the user has selected one dropdown from a category then they need to continue with the rest...Ignore the names on the script....But that sort of idea with dropdowns Last edited by shaunlevett; 03-19-2008 at 10:05 AM. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|