Click here to Skip to main content
15,886,362 members
Home / Discussions / JavaScript
   

JavaScript

 
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 
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 
Yes, something very very very basic. You need to look at the AJAX script.

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){
          if(document.getElementById('users').checked) document.getElementById('users').value = '1';
          else document.getElementById('users').value = '0';
          document.getElementById('#ex11').innerHTML += "Value saved!";
      }
  }
 
  xmlhttp.open("GET","[LOCATION TO PHP SCRIPT HERE]?value=" + value,true);
  xmlhttp.send();
}


Then just make sure you set the 'id' attribute on your checkbox.

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


Keep in mind what the value should start as based on the value from the database if needed. That's opening a whole new can of worms. You're going to need to get the current value from the database with PHP, and then use and if-else like the one in the javascript above to set the initial value.

There are a lot of things going on in your script, you really have to keep your mind open and figure out the logic behind everything that's happening to be a successful programmer.

Good luck!

-Evan
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 
GeneralRe: JavaScript class problem Pin
Wjousts25-Aug-11 7:58
Wjousts25-Aug-11 7:58 
Questionjquery dialog autosize [modified] Pin
fififlowertot24-Aug-11 3:05
fififlowertot24-Aug-11 3:05 

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.