[Javascript] checkbox to change input field value

David Dorward david at dorward.me.uk
Mon May 22 07:40:39 CDT 2006


On Mon, May 22, 2006 at 01:28:34PM +0100, Alan Easton wrote:
>    I have the five checkbox values: allvalues=7865, 7866, 7867, 7868, 7869
> 
>    And then the ones that WERE checked: checkval=7865, 7868, 7869
> 
>    I am just not sure on the checking syntax I would have to use.....any
>    ideas.......??

Assuming you have them in arrays and not comma-seperated lists, and
keeping in mind that I have never done server side JS in ASP (and had
forgotten it was possible, hence my previous comments assuming you
were trying to get the browser to return the inverse of what it would
normally return), then something like (untested):

...
var inverseList = new Array();
var browserList = ...;
var fullList = ...;

for (var i = 0; item = fullList[i]; i++){
  if (inList(item, browserList)) {
    inverseList.push(item);
  }
}

function inList(var sought, var list) {
  for (var i = 0; item = list[i]; i++) {
    if (item == sought) {
      return 1;
    }
  }
  return 0;
}  


-- 
David Dorward                                      http://dorward.me.uk




More information about the Javascript mailing list