Page 1 of 1

javascript alert if set value it displayed in a select list

Posted: Sat Sep 15, 2012 5:09 am
by jonnyfortis
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

Re: java alert if a set value it displayed in a select list

Posted: Mon Sep 17, 2012 2:31 am
by Gopesh
Hi,
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{
}
});
});
Hope that u uses jquery.

Re: java alert if a set value it displayed in a select list

Posted: Mon Sep 17, 2012 4:31 am
by jonnyfortis
sorry about that , yes i know tey are different, i was rushing..

Re: javascript alert if set value it displayed in a select l

Posted: Mon Sep 17, 2012 4:38 am
by jonnyfortis
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?