Jump to content

onSelect/onDeselect can't get both too work


Kay1021

Recommended Posts

I'm kinda a newbie to Javascript but i have seemed to figure out one part of what i am trying to do and need help with the second part. What i am trying to do is this checkbox that has a style from here http://lipidity.com/fancy-form/. But what i wanted was that once you click select or deselect the checkbox that it is automatically updated to the database. I was already doing something like this with a textarea and i finally figured out how to get it to work with my checkbox. I used part of the help the site gave..

FancyForm.start( 0, {
onSelect: function(chk){
	alert(chk.inputElement.getProperty('name'));
}
});

 

 

and rearranged it and used some of my other code and got it to actually work for what i need. My code:

FancyForm.start(0, {
	onSelect: function(chk) {		
		var url = 'schoolPage.php?catID=' + chk.inputElement.getProperty('id') + '&chk=' + chk.inputElement.getProperty('checked');
			var request = new Request({
				url:url,
				method:'POST',
				onRequest: function() {
					alert('making sure it works:: ' + url);
				}
			}).send();


	}

});

 

so that works ....and if change it to onDeselect it works....when you uncheck a box....however  i some how need them both in there....and so when you select or deselect the box that it will send the info. Being new to javascript I just can figure out the proper way to do this...if just put both things get messed up and what not. Could someone please help me out?

 

Link to comment
Share on other sites

Have you tried:

 

FancyForm.start(0, {
      onSelect: function(chk) {      
         var url = 'schoolPage.php?catID=' + chk.inputElement.getProperty('id') + '&chk=' + chk.inputElement.getProperty('checked');
            var request = new Request({
               url:url,
               method:'POST',
               onRequest: function() {
                  alert('making sure it works:: ' + url);
               }
            }).send();
      }
      onDeselect: function(chk) {      
         // deselect code here
      }
   });

Link to comment
Share on other sites

Yes i tried writing it like that and it gets rid of the styles which is the whole point of using the fancy form checkbox. Plus it doesn't do anything anyways...no alert pops up like its suppose to. That's why i thought maybe i was writing it wrong....or there was another way to do it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.