i have a select list that is populated from a php mysql DB. if the words. " finished" are entered into the select lost ( from the backend) when the user selects the word "finished" and try's to submit the for i need an alert to say " sorry you cant select this option"
how can this be done
thanks in advance
javascript alert if set value it displayed in a select list
Moderator: General Moderators
-
jonnyfortis
- Forum Contributor
- Posts: 462
- Joined: Tue Jan 10, 2012 6:05 am
javascript alert if set value it displayed in a select list
Last edited by jonnyfortis on Mon Sep 17, 2012 4:33 am, edited 3 times in total.
Re: java alert if a set value it displayed in a select list
Hi,
First off all change the title from java to javascript bcoz java and javascript are entirely different.
try this
Hope that u uses jquery.
First off all change the title from java to javascript bcoz java and javascript are entirely different.
try this
Code: Select all
$(function() {
$('#selectlistid').change(function() {
var value = $(this).val();
if (value=='finished'){
alert("Message");
}else{
}
});
});
-
jonnyfortis
- Forum Contributor
- Posts: 462
- Joined: Tue Jan 10, 2012 6:05 am
Re: java alert if a set value it displayed in a select list
sorry about that , yes i know tey are different, i was rushing..
-
jonnyfortis
- Forum Contributor
- Posts: 462
- Joined: Tue Jan 10, 2012 6:05 am
Re: javascript alert if set value it displayed in a select l
ok so i add this javascript then in the form add a function?
can i do it that if the field has more than "finshed" in the text string it will just recognize that word
e.g if in the select list it as 2-4 years (finished) it will recognize this aswell?
can i do it that if the field has more than "finshed" in the text string it will just recognize that word
e.g if in the select list it as 2-4 years (finished) it will recognize this aswell?