Welcome Guest, Not a member yet? Register   Sign In
How to check form_dropdown() with javascript?
#5

[eluser]ggoforth[/eluser]
There are various ways of doing it. I use jquery so I will show you that way, and also how to do it with basic javascript.

Basic

Code:
//select the element by it's id
var my_dropdown_val = docuement.getElementById('my_dropdown').value();
//do something with the value of the dropdown
alert(my_dropdown_val);

Next is how you could do it with jquery:

Code:
var my_dropdown_val = $('#my_dropdown').val();
alert(my_dropdown_val);

Just throw these in a function that you can call on change of the dropdown, with jquery it would look like:

Code:
$(docuement).ready(function(){
    $('#my_dropdown').change(function(){
         alert($(this).val());
    });
});

That is a few different ways you could do it. I would highly recommend looking into a javascript frame work like jquery. It will make your life a lot easier.

Greg


Messages In This Thread
How to check form_dropdown() with javascript? - by El Forum - 06-28-2009, 08:23 PM
How to check form_dropdown() with javascript? - by El Forum - 06-28-2009, 08:27 PM
How to check form_dropdown() with javascript? - by El Forum - 06-28-2009, 09:09 PM
How to check form_dropdown() with javascript? - by El Forum - 06-28-2009, 09:14 PM
How to check form_dropdown() with javascript? - by El Forum - 06-28-2009, 09:14 PM



Theme © iAndrew 2016 - Forum software by © MyBB