function remove doesn't work, please help...

Discussion in 'JavaScript' started by s.jns, Oct 30, 2010.

  1. #1
    Hi, If someone here is willing to help me I would really appreciate

    the function removeInput() of javascript at below not work properly, what i should do?

    <script language="javascript">
    fields = 0;
    function addInput() {
        if (fields != 10) {
            var htmlText =  "<input type='text' name='addfriends[]' value='' size='auto' maxlength='45' /><br />";
            var newElement = document.createElement('div');
            newElement.id = 'addfriend'; 
    	 newElement.innerHTML = htmlText;
    
            var fieldsArea = document.getElementById('addfriend');
    	fieldsArea.appendChild(newElement);
    
            fields += 1;
        } else {
            alert("Only 10 friends allowed.");
            document.form.add.disabled=true;
        }
    }
    //field = 0;
    function removeInput() {
    		var div = document.getElementById('addfriend');
            var lastElement = document.removeElement('div');
            lastElement.id = 'addfriend'; 
    		if (lastElement > 2) div.Element(lastElement - 1);
    
    }
    </script>
    Code (markup):
    Thanks a lots
     
    s.jns, Oct 30, 2010 IP
  2. krsix

    krsix Peon

    Messages:
    435
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    What is removeInput supposed to do? AFAIK .id and .removeElement and .Element aren't real functions
     
    krsix, Oct 30, 2010 IP
  3. s.jns

    s.jns Greenhorn

    Messages:
    90
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #3
    I actually do not know how it should be, I'm just trying to follow the previous one (function addInput()), I just try it, so if you want give me a way out is pleased to help me, i very glad.
     
    s.jns, Oct 30, 2010 IP