Help w/ Drop-Down Menu (Select / Option)
Moderator: General Moderators
Re: Help w/ Drop-Down Menu (Select / Option)
The functions are separate. The trouble is they're targeting an ID, which is meant to be unique but isn't. You're creating multiple forms inside a loop and giving them all the same ID. Rather than selecting the ID within the function, try using the calling item instead.
Re: Help w/ Drop-Down Menu (Select / Option)
ok, so I removed the onChange event and put a submit button instead and it works. So, as you suggested, the problem is related to the javascript code. I'm sorry, but what do you mean by "try using the calling item instead?" I googled "calling item" and think you're meaning something with the "#assign_contractor." Could you show me what you mean?
Re: Help w/ Drop-Down Menu (Select / Option)
Remove the ID since it's not going to be unique. Use a class instead and set a listener on that class' change event.
Something like this
Something like this
Code: Select all
$(function() {
$('.assign_contractor').change(function() {
$(this).submit();
});
})();
Re: Help w/ Drop-Down Menu (Select / Option)
So there's something to be said for walking away from something for a little time and coming back to it.
I found, what I guess was a mistake in your function, and changed it to look more like the current functions I have. Then it occurred to me the class you were referring to could be put in the <form>, which I didn't know you could do.
Now it all seems to be working as hoped.
Long and hard lessons, but good ones for my growing toolbox.
Also didn't know you could:
specifically, the ['assign_contractor'] part.
Funny how CLOSE I've come, over the 100 iterations I've tried, to something very similar to what I have now; excluding the javascript piece of course. It was the one hidden element in the form that was the biggest oversight.
Ok, so thank you again very much. Couldn't have gotten here without your help.
I found, what I guess was a mistake in your function, and changed it to look more like the current functions I have. Then it occurred to me the class you were referring to could be put in the <form>, which I didn't know you could do.
Now it all seems to be working as hoped.
Long and hard lessons, but good ones for my growing toolbox.
Also didn't know you could:
Code: Select all
$contractor = mysqli_real_escape_string($con, $_POST['assign_contractor']);Funny how CLOSE I've come, over the 100 iterations I've tried, to something very similar to what I have now; excluding the javascript piece of course. It was the one hidden element in the form that was the biggest oversight.
Ok, so thank you again very much. Couldn't have gotten here without your help.