|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
form not passing variable
Hi all,
I recently got some help from the HTML programming section on creating a dependent dropdown list - that is, choosing an item from one select menu would cause a particular 2nd select menu to appear. The good folks in that thread helped me with a javascript bit that I had found (I really don't know any javascript). That thread is here: http://forums.devshed.com/t262187/s.html Anyway, it works great but the item chosen in the 2nd dropdown (select menu) does not get passed to the action page when the form is submitted. Here is my setup: Table 1 = State (6 states listed) Table 2 = Station, State (>100 stations listed) Purpose: when a state is selected from the first dropdown (populated by table 1) fill the 2nd dropdown with those stations that have a matching state. Here is a bit of my code on the form: PHP Code:
Now here is the code I have on my action page PHP Code:
No matter what I choose from the second dropdown the very first item in the station list gets submitted every time. Can anyone recognize what I"m doing wrong? Sorry for the long spout of code! melissa |
|
#2
|
|||
|
|||
|
I'm pretty sure its a problem with your Javascript code. You might want to post it to the Javascript forum if no one here can give a good answer.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
|||
|
|||
|
I guess I was wondering if I was passing the right variable? And if the code on the submit page is correct?
I think the JS is okay since the form works like it's supposed to. But if no one here can help I'll give a shout over in the other forum. Thanks! ![]() melissa |
|
#4
|
|||
|
|||
|
On the action page do a <cfdump var="#form#"><cfabort> and see if the variable you think should be in the form scope is actually there and what its value is.
|
|
#5
|
|||
|
|||
|
Cool! I never used that before.
![]() I figured out what was happenning - because there was no blank line at the top of each dropdown every form variable (stationCA, stationID, stationHI, etc) was passing something. Once I put in a blank option before outputting the query it was fine! In other words, the form needed the bold line for every select dropdown: PHP Code:
Thanks (again and again) kiteless! I learn something new from you every time. Cheers, melissa |
|
#6
|
|||
|
|||
|
That tip as well as some others are in the sticky threads at the top of the CF forum! Give them a look.
![]() |
|
#7
|
|||
|
|||
|
Will do - sorry I didn't before!
![]() May I ask one more question? This might actually belong back in the html programming forum, or maybe even javascript but what the heck, it's worth a shot . . . The guy I'm building this form for wants the station field to be required. When I try to use the hidden variable I get the "field is required" message even when I choose something. Why is that? I have this below the javascript from above: Code:
<input type="hidden" name="station_required" value="Please choose a station or division"> |
|
#8
|
|||
|
|||
|
Quote:
Looking at the code in the thread above, you don't have a field with name="station" unless of course that's changed in your code. To get the hidden required field, the name must be the same as an actual field in existence + "_required" |
|
#9
|
|||
|
|||
|
Doh! You are right! I completely missed that!
So how would I code it for these multiple select statements? Really just one value is required. Do I need an if/else statement? |
|
#10
|
|||
|
|||
|
Quote:
I'm not sure what you are asking. Do you mean how you code for the hidden field on the front end? Or something else on the processing end? |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > form not passing variable |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|