You have to return true.
<input id="still_working_1" name="still_working" onclick='stillWork
> ("#still_working_1"); return true;' type="checkbox">

return false means don't do the change

I don't like the way the javascript is written

Use the bind function with the onchange (change event) and use in the
callback the this value (read more in the internet and jquery
documantation how to use it)

Good Luck,
David

On Jan 18, 5:38 pm, Toaster <mr.toas...@gmail.com> wrote:
> js:
> ------------------------------------------------
>                function stillWork(id) {
>                         if ($(id).attr('checked') == true)
>                         {
>                              alert('check');
>                         }
>                         if ($(id).attr('checked') == false)
>                         {
>                              alert('uncheck');
>                         }
>                 }
> -------------------------------------------------
>
> html:
> ------------------------------------------------
> <input id="still_working_1" name="still_working" onclick='stillWork
> ("#still_working_1"); return false;' type="checkbox">
> ------------------------------------------------
>
> (theres more to the html but is this enough?)
>
> On Jan 18, 12:46 pm, david <michaelg...@gmail.com> wrote:
>
> > Have no idea. Can you send the code ?
>
> > On Jan 18, 4:35 pm, Toaster <mr.toas...@gmail.com> wrote:
>
> > > Hello david,
>
> > > Thank you for your reply.
>
> > > I've changed the if statement to .atrr('checked') like you mentioned.
> > > I am having one problem though, when I click the box, it changes its
> > > status  back to default after executing the js. For example, I have an
> > > alert within the if statement.. when I check it for example, it stays
> > > checked just until I click ok on the alert then it goes back to
> > > unchecked. Have any idea on what is happening?
>
> > > On Jan 18, 11:59 am, david <michaelg...@gmail.com> wrote:
>
> > > > I am giving you general pointers to functions:
> > > > use the bind function to registrar the checkbox for the onchange event
> > > > in the callback function check if the checkbox is checked through the
> > > > attr( 'checked' ) function
>
> > > > by the way i think the value of disabled is "disabled"
>
> > > > Good Luck,
> > > > David
>
> > > > On Jan 18, 3:32 pm, Toaster <mr.toas...@gmail.com> wrote:
>
> > > > > Hey
>
> > > > > I was wondering on how I might be able to have a checkbox that when
> > > > > checked or unchecked would disable or enable a dropdown.
>
> > > > > I am still very new to jQuery but this is what I have but doesnt work.
>
> > > > > ----------------------------------------------------------------------------
> > > > >                 function stillWork(id) {
> > > > >                         if ($(id).is(':checked'))
> > > > >                         {
> > > > >                         $("#work_month_end_1").attr("disabled", true);
> > > > >                         $("#work_year_end_1").attr("disabled", true);
> > > > >                         }
> > > > >                         if ($(id).not(':checked'))
> > > > >                         {
> > > > >                         $("#work_month_end_1").removeAttr("disabled");
> > > > >                         $("#work_year_end_1").removeAttr("disabled");
> > > > >                         }
> > > > >                 }
> > > > > ----------------------------------------------------------------------------
>
> > > > > I also experimented with a couple other ways and it usually gives me a
> > > > > problem where it automatically unchecks a box after checking it/
> > > > > running the js.
>
> > > > > Thanks in advance

Reply via email to