[jQuery] Re: show input field base on selected option

2010-02-17 Thread 123gotoandplay
this is what i have now

$('#numOfHours').hide();

 $('#type').change(function() {
if($('#type :selected').text() == parttime) {
$('#numOfHours').show();
} else {
$('#numOfHours').hide();
}

On Feb 17, 2:08 pm, 123gotoandplay wesweatyous...@gmail.com wrote:
 How do i show a input field only when a certain option is selected?
 and hide if it isn't selected

 regards


[jQuery] Re: show input field base on selected option

2010-02-17 Thread 123gotoandplay
solution:

 $('#type').change(function() {

if($('#type :selected').val() === parttime) {
$('#numOfHours').show();
} else {
$('#numOfHours').hide();
}
})


Re: [jQuery] Re: show input field base on selected option

2010-02-17 Thread Jonathan Vanherpe (T T nv)

maybe something like this?
$(function(){
   $('#type').change(function(){
   var selected = $(this).children().filter(':selected');
   if(selected.val()=='parttime'){
   $('#numOfHours').show();
}else{
   $('#numOfHours').hide();
}
});
});

This is untested, and can probably be written a lot shorter.

Throw a couple of console.log(); lines in there and I'm sure you'll 
figure out what's wrong. If it still doesn't work, post your page online 
somewhere.


Jonathan

123gotoandplay wrote:

this is what i have now

$('#numOfHours').hide();

 $('#type').change(function() {
if($('#type :selected').text() == parttime) {
 $('#numOfHours').show();
 } else {
 $('#numOfHours').hide();
 }

On Feb 17, 2:08 pm, 123gotoandplaywesweatyous...@gmail.com  wrote:

How do i show a input field only when a certain option is selected?
and hide if it isn't selected

regards





--
Jonathan Vanherpe - Tallieu  Tallieu nv - jonat...@tnt.be