Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Javascript] checkbox to change input field value


  • From: david at dorward.me.uk (David Dorward)
  • Subject: [Javascript] checkbox to change input field value
  • Date: Mon May 22 07:40:43 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