0

I have this html

<form id="form">

<input id="deleteNumber" name="del" type="hidden" />
<input id="addAddress" name="addAddress" type="hidden" />

...
...
...

<a href="javascript:deleteAddress();" class="deleteItem"/></a>
<a href="javascript:addNextAddress()">Add address </a>
</form>

<script type="text/javascript">
function addNextAddress() {
    var parent = document.getElementById('form');
    var child = document.getElementById('form').del;
    perent.removeChild(child);
    document.getElementById('form').submit();   
}
</script>
<script type="text/javascript">
function deleteAddress() {
    var r=confirm(text);
    if (r == true) {
        var parent = document.getElementById('form');
        var child = document.getElementById('form').addAddress;
        perent.removeChild(child);
        document.getElementById('form').submit();
    }
}
</script>

I get js error:

Uncaught ReferenceError: perent is not defined

Can anybody help?

3 Answers 3

2

its just a typo in this function:

function addNextAddress() {
    var parent = document.getElementById('form');
    var child = document.getElementById('form').del;
    perent.removeChild(child);//<-- change perent to parent
    document.getElementById('form').submit();   
}
Sign up to request clarification or add additional context in comments.

Comments

1

try now

var parent = document.getElementById('form');
var child = document.getElementById('form').addAddress;
parent.removeChild(child);
document.getElementById('form').submit();

or change Parent to perent :)

1 Comment

There's a campaign to clean up Stack Overflow by removing these typo-related questions - we could really use your help! Would you mind pitching in a little by casting a close vote on this question?
0

Change perent.removeChild(child) to parent.removeChild(child).

You have a spelling mistake -- perent is not defined anywhere in your code, which is why you see "perent is not defined".

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.