Results 1 to 2 of 2

Thread: Incompatible Functions?

  1. #1
    Join Date
    Feb 2005
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Incompatible Functions?

    Howdy,

    I have two separate functions, both which work as intended but only if executed separately (i.e. from two separate buttons). Problem is, I can neither combine these into one function, nor execute with a onclick="formtypearray();testthis();" event.

    Code:
    function formtypearray()
    {
    	document.getElementById('FunctionArray').value = '';
    
    	var incominglist;
    	incominglist = document.getElementById('PeopleArray').value;
    	
    	var str = incominglist;
    	var a1  = new Array();
    	a1 = str.split("|");
    	
    	for (i=0;a1.length-1;i++)
    	{
    		a1[i] = document.getElementById(a1[i]+'2').value;
    		document.getElementById('FunctionArray').value = document.getElementById('FunctionArray').value.concat('|',a1[i]);
    	}
    }
    
    function testthis()
    {
    	var thestring;
    	thestring = document.getElementById('FunctionArray').value;
    
    	document.getElementById('FunctionArray').value = thestring.substr(1);
    }
    Can anyone enlighten me as to why I can't combine these into one function like this? (or run the two functions separately in one onclick event)?

    Code:
    function formtypearray()
    {
    	document.getElementById('FunctionArray').value = '';
    
    	var incominglist;
    	incominglist = document.getElementById('PeopleArray').value;
    	
    	var str = incominglist;
    	var a1  = new Array();
    	a1 = str.split("|");
    	
    	for (i=0;a1.length-1;i++)
    	{
    		a1[i] = document.getElementById(a1[i]+'2').value;
    		document.getElementById('FunctionArray').value = document.getElementById('FunctionArray').value.concat('|',a1[i]);
    	}
    
    	var thestring;
    	thestring = document.getElementById('FunctionArray').value;
    
    	document.getElementById('FunctionArray').value = thestring.substr(1);
    }
    Thanks,

    - I

    PS - Let me know if you need any more detail - such as the HTML code.

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Should be fine. Note that the second function will overwrite the value given to FunctionArray by the first, though.

    An URL would be nice.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

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
  •