Click here to Skip to main content
15,885,546 members
Home / Discussions / JavaScript
   

JavaScript

 
GeneralRe: Help with Ajax Pin
ShenDraeg8-Sep-11 6:40
ShenDraeg8-Sep-11 6:40 
GeneralRe: Help with Ajax Pin
ShenDraeg16-Sep-11 9:16
ShenDraeg16-Sep-11 9:16 
AnswerRe: Help with Ajax Pin
ShenDraeg13-Sep-11 9:09
ShenDraeg13-Sep-11 9:09 
Questionproblem with Joomla template - jQuery conflict mootols Pin
nikolay1006-Sep-11 0:04
nikolay1006-Sep-11 0:04 
AnswerRe: problem with Joomla template - jQuery conflict mootols Pin
nikolay1008-Sep-11 19:44
nikolay1008-Sep-11 19:44 
GeneralRe: problem with Joomla template - jQuery conflict mootols Pin
Firo Atrum Ventus8-Sep-11 20:09
Firo Atrum Ventus8-Sep-11 20:09 
Questionsimple javascrpt: checkbox Pin
AndyInUK2-Sep-11 7:13
AndyInUK2-Sep-11 7:13 
AnswerRe: simple javascrpt: checkbox Pin
Evan Gallup3-Sep-11 19:08
Evan Gallup3-Sep-11 19:08 
The way I would do so (if you want to do it on the fly, without the user changing pages) is to use AJAX. It's really quite simple actually, don't let AJAX scare you off if you haven't ventured into it yet.

JavaScript
function saveCheckBoxValue(value)
{
  var xmlhttp;
  if (window.XMLHttpRequest){
      xmlhttp = new XMLHttpRequest();
  }
  else{
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  }

  xmlhttp.onreadystatechange=function(){
      if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
          [DO SOMETHING HERE SUCH AS THE EXAMPLE BELOW THIS]
          document.getElementById('#ex11').innerHTML += "Value saved!";
      }
  }

  xmlhttp.open("GET","[LOCATION TO PHP SCRIPT HERE]?value=" + value,true);
  xmlhttp.send();
}


Then, in the HTML code for your checkbox, all you must do is this:

<input type="checkbox" id="ex11" value="" onchange="saveCheckBoxValue(this.value)" />


Not sure if this is what you were looking for, but I figured I'd give my two cents. The best part about this is that you can create multiple checkboxes, but still only use that one js function to save the values. You will most likely need to tweak this to your needs, such as the value that the checkbox must have, but it's a start at least.

Happy coding! Big Grin | :-D
GeneralRe: simple javascrpt: checkbox Pin
AndyInUK5-Sep-11 5:43
AndyInUK5-Sep-11 5:43 
GeneralRe: simple javascrpt: checkbox Pin
Evan Gallup5-Sep-11 6:53
Evan Gallup5-Sep-11 6:53 
QuestionXML and Javascript Pin
Member 820418431-Aug-11 19:26
Member 820418431-Aug-11 19:26 
QuestionRe: XML and Javascript Pin
DaveAuld31-Aug-11 22:43
professionalDaveAuld31-Aug-11 22:43 
AnswerRe: XML and Javascript Pin
Evan Gallup3-Sep-11 19:39
Evan Gallup3-Sep-11 19:39 
Questioniphone style switch Pin
AndyInUK30-Aug-11 23:07
AndyInUK30-Aug-11 23:07 
AnswerRe: iphone style switch Pin
AndyInUK2-Sep-11 1:06
AndyInUK2-Sep-11 1:06 
QuestionJavaScript class problem [modified] Pin
Wjousts25-Aug-11 6:09
Wjousts25-Aug-11 6:09 
AnswerRe: JavaScript class problem Pin
Graham Breach25-Aug-11 6:34
Graham Breach25-Aug-11 6:34 
GeneralRe: JavaScript class problem Pin
Wjousts25-Aug-11 7:40
Wjousts25-Aug-11 7:40 
AnswerRe: JavaScript class problem Pin
AspDotNetDev25-Aug-11 7:45
protectorAspDotNetDev25-Aug-11 7:45 
GeneralRe: JavaScript class problem Pin
Wjousts25-Aug-11 8:06
Wjousts25-Aug-11 8:06 
GeneralRe: JavaScript class problem Pin
AspDotNetDev25-Aug-11 8:11
protectorAspDotNetDev25-Aug-11 8:11 
GeneralRe: JavaScript class problem Pin
Wjousts25-Aug-11 8:18
Wjousts25-Aug-11 8:18 
AnswerRe: JavaScript class problem Pin
AspDotNetDev25-Aug-11 7:19
protectorAspDotNetDev25-Aug-11 7:19 
GeneralRe: JavaScript class problem Pin
Wjousts25-Aug-11 7:43
Wjousts25-Aug-11 7:43 
AnswerRe: JavaScript class problem Pin
AspDotNetDev25-Aug-11 7:47
protectorAspDotNetDev25-Aug-11 7:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.