Javascript-форум (https://javascript.ru/forum/)
-   Общие вопросы Javascript (https://javascript.ru/forum/misc/)
-   -   Нужно добавить новый div после нажатия на <a> (https://javascript.ru/forum/misc/54300-nuzhno-dobavit-novyjj-div-posle-nazhatiya-na.html)

supvlmail 12.03.2015 16:32

Нужно добавить новый div после нажатия на <a>
 
Посмотрите, пожалуйста в чем ошибка. Я в javascript новичек.
Код:

<head>
        <title>Документ без названия</title>
    <script>
                function choiceFirstForm() {
                        var newSite = getElementById("newSite");
                        var psd = getElementById("psd");
                        var template = getElementById("template");
                                if(newSite.click()) {
                                newSite.setAttribute(checked)
                                psd.removeAttribute(checked)
                                template.removeAttribute(checked)
                                }
                        }
                function firstChoice() {
                        if(newSite.hasAttribute(checked)) {
                                var firstForm = getElementByName("firstForm");
                                var newSite = getElementById("newSite");
                                var div = document.createElement("div");
                                div.innerHTML = "Вы выбрали Новый";
                                this.parentNode.insertBefore(div, this.nextSibling);
                                }
                        }
        </script>
</head>
<body>
        <form name="firstForm">
            <input type="radio" name="create" id="newSite" onClick="choiceFirstForm()"/><br />
        <input type="radio" name="create" id="psd" onClick="choiceFirstForm()"/><br />
        <input type="radio" name="create" id="template" onClick="choiceFirstForm()"/><br />
        <a href="#" onClick="firstChoice()">Выбрать</a>
    </form>   
</body>



Часовой пояс GMT +3, время: 21:42.