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

    Remove entry from array and repost form

    Hi all,

    I am trying to accomplish a fairly basic task with javascript > my lack of Js knowledge has meant i have hit something of a roadblock.

    I need the a function to take an array from a form, remove the parsed variable from it and repost the form with the new array.

    This is what I have so far...

    Code:
    <script language="javascript">
    
    	function remove(SID) {
    
    		var speakers = document.form_name.elements["SID[]"];
    		var new_speakers = array();
    
    		for(i=0;i<speakers.length;i++)
    		{
    		 	if( speakers[i].value !== SID) { 
    			
    				new_speakers[] = speakers[i].value;	
    
    			}
    		}
    
    		document.form_name.SID.value=(new_speakers); 
    	
    		document.form_name.submit();
    
    	}
    
    </script>
    Please let me know if this is possible and if I'm on the right path.

    Any help is very much appreciated!!

    Thanks

    Steve
    You think anybody wants a roundhouse kick to the face while I'm wearing these bad boys? Forget about it.
    <!------------o\/o-----------?>

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,928
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    var new_speakers = new Array();

    new_speakers[i] = speakers[i].value;

    document.form_name.SID.value = new_speakers; // no brackets necessary
    Last edited by Philip M; 03-16-2009 at 01:39 PM.

  • Users who have thanked Philip M for this post:

    Schteeve (03-16-2009)

  • #3
    New Coder
    Join Date
    Jun 2007
    Posts
    27
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Smile

    Thanks Phillip.

    All sorted now!

    Thanks for your help!
    You think anybody wants a roundhouse kick to the face while I'm wearing these bad boys? Forget about it.
    <!------------o\/o-----------?>


  •  

    Posting Permissions

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