Results 1 to 7 of 7

Thread: Exclude action on Index 0 and 1 in a Combo Box onChange event

  1. #1
    Join Date
    Nov 2019
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Exclude action on Index 0 and 1 in a Combo Box onChange event

    Hi experts,

    On my website, www.vannturner.com, I have 8 combo boxes which list the URLs of retailers (the actual product page) where my novels can be bought.

    Index 0 is always the name of the name of the box, eg “Retailers”. Most have Index 1 as Your local bookstore. Both of those have an empty string as arg.

    On the onChange event, I am passing as arg the URL to the gothere function. It works just fine for Indexes 2 and greater, but if someone selects Index 1, it opens a copy of my URL in a new window.

    How to tell the script that if Index 0 or 1 is selected to do nothing?

    WORKS, but does not exclude Index 0 or 1:

    Code:
    <script type="text/javascript">
    function gothere(arg){
    var arg 
    newwindow=window.open("")
    newwindow.location=arg;
    }
    </script>
    My attempt to exclude the first two items in the box. DOES NOT WORK:
    Code:
    <script type="text/javascript">
    function gothere_new(arg){
    	var arg 
    	if(arg != null && arg.length() < 2) { return;}
    	else {
    		newwindow=window.open("")
    		newwindow.location=arg;
    	}
    }
    </script>
    I admit I have not studied Java, but have a background in VB and dot.Net. I'm sure my syntax is just wrong.

    What is the correction?

    Thanks for your help!
    Vann
    Last edited by james438; 11-05-2019 at 01:15 AM. Reason: formatting

  2. #2
    Join Date
    Nov 2006
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,365
    Thanks
    1
    Thanked 243 Times in 238 Posts

    Default

    Hi there vturner,

    and a warm welcome to these forums.

    Try it like this...

    Code:
    
    
    function gothere( arg ){
       if ( arg !== '' ) {
            window.open( arg );
       }
     }

    coothead
    Last edited by coothead; 11-05-2019 at 03:39 PM.
    ~ the original bald headed old fart ~

  3. #3
    Join Date
    Nov 2019
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    coothead, MANY THANKS!

    Works perfectly. And I'm indebted.
    If I can ever do anything for you, merely ask.

    Vann

  4. #4
    Join Date
    Nov 2006
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,365
    Thanks
    1
    Thanked 243 Times in 238 Posts

    Default


    Quote Originally Posted by vturner View Post
    If I can ever do anything for you, merely ask.
    To be on the the safe side, I would
    suggest that you remove this...

    Code:
    
    function gothere_new(arg){
    	var arg 
    	if(arg != null && arg.length() < 2) { return;}
    	else {
    		newwindow=window.open("")
    		newwindow.location=arg;
    	}
    }
    
    function gothereORIG(arg){
    var arg 
    newwindow=window.open("")
    newwindow.location=arg;
    }
    
    Then you may smile benignly.

    coothead
    Last edited by coothead; 11-05-2019 at 03:39 PM.
    ~ the original bald headed old fart ~

  5. #5
    Join Date
    Nov 2019
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    coothead,

    Good idea. I'll remove it since it has no use.

    Your willingness to help a stranger speaks well of you.

    You are probably a man greatly loved, with many friends. Easy to see why.

    Best wishes,
    Vann

  6. #6
    Join Date
    Nov 2006
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,365
    Thanks
    1
    Thanked 243 Times in 238 Posts

    Default


    Quote Originally Posted by vturner View Post
    You are probably a man greatly loved, with many friends.
    It is funny that you should say that as I'm actually a
    recluse and don't have any friends as such.

    What I do though, is try to treat everyone that I meet
    with respect and of course, as a result, I always...

    smile benignly

    coothead
    ~ the original bald headed old fart ~

  7. #7
    Join Date
    Nov 2019
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi coothead,

    Somehow I missed this yesterday in my in-box.

    We've got something in common. I too am somewhat a recluse here in the mountains with my dogs, woodstove, mountains, forest and sky. I'm fortunate that I have excellent neighbors (though you see their their houses from mine). We do for each other, whatever is needed. I'll be walking over in a bit a tend one of my neighbors' dogs, as a funeral in the family has called them away. And I, too, try to treat everyone respectfully. (Love your "smile benignly" closing.

    Vann

Similar Threads

  1. Replies: 0
    Last Post: 07-07-2015, 10:06 AM
  2. Resolved Javascript validation onchange event
    By dragon_sa in forum JavaScript
    Replies: 2
    Last Post: 03-04-2012, 01:56 AM
  3. how to force fire the onChange event
    By rizlaa in forum JavaScript
    Replies: 5
    Last Post: 03-15-2009, 10:54 PM
  4. onChange Event not happening ..(:
    By eric_2005 in forum JavaScript
    Replies: 8
    Last Post: 06-17-2006, 03:43 PM
  5. Form Select Menu onChange Event for Dates
    By wps in forum JavaScript
    Replies: 0
    Last Post: 08-22-2005, 12:08 PM

Bookmarks

Posting Permissions

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