Re: Can't getElementById on document.createElement dynamically

Sunday, October 13, 2013


Popup Window ... The term actually now refers to two different types of visuals.  One is an actual window, and the other is a DIV tag that appears above the content of the current page.  To write a form dynamically between browser Windows may require using JavaScript calls between them - similar to calling frames. I can talk more about that, if that is the version you are trying to build.  What follows is for a popup DIV.

For this example, I'm assuming you mean a DIV that appears above the content.  There are 4 CSS values that affect this ... position : absolute;  visibility : hidden; display : none, and z-index : 50 or higher.  You might also need to set left, top, width and height as well.

To make the DIV appear change visibility : visible; display : block;

Using the previous example ... I used a SCRIPT tag to contain HTML.  I would suggest that you use this example for your site as well. Create SCRIPT tags that contain your forms, and then copy the script into the popup DIV as needed.

var szTemplate = $("#template_form_1").html();
$("#popup").html (szTemplate);
$("#popup").css ("visibility ", "visible").css ("display ","block");


put each form in a hidden DIV tag, and then make the DIV appear where you need it.

$("#form_1").css ("visibility ", "visible").css ("display ","block");

    position : absolute;

    display : none;

    width : 100%;
    height : 100%;

    z-index : 50;

    float : none;
    clear : both;

<div id="form_1" class="hiddenDIV">[content]</div>

I hope this helps,


PS .. if you need to disable all content below the popup DIV you need to create another div, with a z-index below the popup div.  This DIV has to cover the entire visible window, and usually has a 50 or 75% dithered white background to shadow the content blow the working DIV.  Then the popup DIV sits on top of that.

On 10/13/2013 4:34 PM, wrote:
Hi Mike:

Yes I just tried it using jquery and I'm not getting any errors.  I do understand that you cannot have the same id. I thought this was the reason
I couldn't get my dynamic form to popup but since  the id its not the problem. I'm back to square one.

Do you have any idea how I can create a dynamic form that has a pop window I'm working on it no luck.
I can write regular HTML with no problem this DOM manipulation is a bit more tricky.  I'm getting there I
believe  this is the last piece I'm missing.  You know how development is there is always something that arises.

This project has so many forms that I have to create and then write more code for button manipulation.
I have the button for the form to pop up which I do with a button.onclick = funciton(){
Its calling my function that creates and appends everything, its just that no form pops up

alert("Appending Divs");
    var regupdateForm=document.createElement('form'); ="dynamicform"; ="regupdate";  
     var updateForm = $(document.getElementById('regupdate'));
    regupdateForm.setAttribute("style"," width:300px;  height:200px; ");
    regupdateForm.setAttribute("target", "_blank");

Thank You For Your Response.
Thanking you in advance.

On Sunday, October 13, 2013 3:03:13 PM UTC-5, wrote:
On my research it points out that you can not get element by id on an element created dynamically is there anyway around it?
  Here is  what I'm trying to do.  I'm aware that I don't have the createElement(select) in yet.  I was trying to get things working first.

 /**************Create Form******************/
 var element = document.createElement('div');   //parent = "updateCCdialog";
   var parent= element.parentNode;

    element.innerHTML = "Update Credit Card"; = "20px"; = "300px";
    element.setAttribute("style"," border:1px solid #06478c;");
    var nextDiv = document.createElement('div');
    nextDiv.className ="dialogWrapper";
    alert("Appending Divs");
    var regupdateForm=document.createElement('form'); ="";  
    alert("Start of form creation");
    var form_Msg = document.createElement('p');
    var msg_Node =document.createTextNode("Are you sure you want to update this card?");
    var formLabel =document.createElement('label'); ="red";
    formLabel.setAttribute("for", description);
    formLabel.innerHTML = "Card Description: ";
    alert("Start of form creation 0");
    var formInput = document.createElement('input'); = "discription";
    formInput.setAttribute('value', des);
    //formInput.value ="";//getvalue from document.creditCardRegister.description.value;
    formInput.type ="text";
    formInput.required ="true";
    var formLabel2 = document.createElement('label'); ="red";
    //formLabel2.setAttribute("for", expiration);
    formLabel2.innerHTML = "Expiration: ";
    alert("Start of form creation2");
    var formselectMonth =  document.createElement('select'); = "expirationMonth";
    formselectMonth.className = "expirationMonth";
    formselectMonth.setAttribute("style"," width:80px;  align:left; ");
     for(var i = 1; i <= 12; i++){
       var option = document.createElement('option');
         option.appendChild(document.createTextNode('0' + i));
    alert("Start of form creation3");
    var nnextDiv = document.createElement('div');
    nnextDiv.className ="UpdateCreditCardActions";
    var formbuttonUpdate = document.createElement('input');
    formbuttonUpdate.type= "submit";
    var formbuttonCancel =document.createElement('input');
    formbuttonCancel.value ="Cancel";
    alert("Is this appending");
    alert("Is this appending0");
     alert("Is this appending2");
    var formselectYear = document.createElement('select');"experationYear";"expirationYear";
    formselectYear.setAttribute("style"," width:50px;  align:left; ");
     for(var i = 2013; i <= 2024; i++){
            var option = document.createElement('option');
            option.appendChild(document.createTextNode('0' + i));
   alert("Start of form creation4");
   parent.insertBefore(nextDiv, element);  //not working never hits my last alert
   alert("Am I making it to the  end")

Thanking you in advance

You received this message because you are subscribed to the Google Groups "JavaScript Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
For more options, visit

No virus found in this message.
Checked by AVG -
Version: 2013.0.3408 / Virus Database: 3222/6747 - Release Date: 10/13/13


Post a Comment

Note: Only a member of this blog may post a comment.

Copyright © 2010 Web Design | Free Blogger Templates by Splashy Templates | Layout by Atomic Website Templates

Vida de bombeiro Recipes Informatica Humor Jokes Mensagens Curiosity Saude Video Games Animals Diario das Mensagens Eletronica Rei Jesus News Noticias da TV Artesanato Esportes Noticias Atuais Games Pets Career Religion Recreation Business Education Autos Academics Style Television Programming Motosport Humor News The Games Home Downs World News Internet Design Entertaimment Celebrities 1001 Games Doctor Pets Net Downs World Enter Jesus Mensagensr Android Rub Letras Dialogue cosmetics Genexus lasofia thebushrajr wingshock tripedes gorduravegetal dainfamia dejavu-transpersonal jsbenfica republicadasbadanas ruiherbon iranianforaryans eaystcheyl fotosdanadir Só Humor Curiosity Gifs Medical Female American Health Madeira Designer PPS Divertidas Estate Travel Estate Writing Computer Matilde Ocultos Matilde futebolcomnoticias girassol lettheworldturn topdigitalnet Bem amado enjohnny produceideas foodasticos cronicasdoimaginario downloadsdegraca compactandoletras newcuriosidades blogdoarmario arrozinhoii