Manas
Manas

Reputation: 3330

How can i set another form field based on a checkbox?

I have two check boxes one is to send now and the other is to schedule the send and set the date and time. How do i just let one check box option to be selected and make sure the date and time has been selected if the send at check box is selected?

enter image description here

Upvotes: 0

Views: 38

Answers (1)

Mayank Pandeyz
Mayank Pandeyz

Reputation: 26258

In that case use RADIO instead of CHECKBOX and make sure the two RADIO's have the same name so that only can can be selected at any time like:

<input type="radio" value="1" name="scheduler">Send Now
<input type="radio" value="2" name="scheduler">Send At

You can get the selected radio value by:

$('input[name=scheduler]:checked').val();

And put an if condition like:

if( $('input[name=scheduler]:checked').val() == 1 )
{
    // Do some thing here
}
else
{
    // Do some thing here
}

Upvotes: 2

Related Questions