Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    May 2007
    Thanked 0 Times in 0 Posts

    regex not matching

    I have (0-many) checkboxes outside of a form.
    When one checkbox is selected I want to updated a hidden field inside the form to include that checkbox, so I know they are checked. I am using * as the delimiter.
    similarly when they are unchecked, I would like to remove them from the list.
    However, the code seems to only append once to the hidden field, and then after that, it always be evaluating the reg.test(list) part to be true, so it tries to remove the checkbox name.

    x is the name of the checkbox that the user has just clicked

    function checkValue(x)
    	var list = document.viewMultiple.selectedFiles.value; /**my hidden field**/
    	var reg = new RegExp(x);
    		var xyz = "removing "+x;
    		alert (xyz);
    		var newVar = document.viewMultiple.selectedFiles.value+x+"*";
    		document.viewMultiple.selectedFiles.value = newVar;
    		alert (newVar );		
    I think the problem may be the checkbox names.
    Here is an example of the checkbox name:
    gi|121612266|ref|YP_999723.1| hypothetical proteinCJJ81176_0030 [Campylobacter jejuni subsp. jejuni 81-176]
    Last edited by bluegirl; 05-18-2007 at 10:41 PM. Reason: changed quote to code

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    London, England
    Thanked 2,573 Times in 2,551 Posts
    Seems a complicated way of going about things.

    I have the idea that your problem is the * which in a regex signifies match zero or more occurances, i.e is a meta character.

    For example, /we*/ matches "w" in "why" and "wee" in "between". /x*/ will always return true.


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts