Kay1021 Posted June 18, 2009 Share Posted June 18, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/162707-onselectondeselect-cant-get-both-too-work/ Share on other sites More sharing options...
Adam Posted June 18, 2009 Share Posted June 18, 2009 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 } }); Quote Link to comment https://forums.phpfreaks.com/topic/162707-onselectondeselect-cant-get-both-too-work/#findComment-858727 Share on other sites More sharing options...
Kay1021 Posted June 18, 2009 Author Share Posted June 18, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/162707-onselectondeselect-cant-get-both-too-work/#findComment-859026 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.