Re: JavaScript Form created dynamically with ability to make more forms form name does not work after first creation

Monday, November 18, 2013


I found out what the issue is.  I could kick myself for not turning on the debugger.  These small things can cause you to loose
and waste time and I'm perturbed. 

The was I had

document.formname.description.value;  //It seems this way would only work for the one form I created

should have been

document.forms["formname'] .description.value  //This will work even if the form has the same name


On Friday, November 15, 2013 1:49:37 AM UTC-6, wrote:

I thought my form update issue was a counter issue, so I created counters for my created elements.  Once I got the counters
working I realized that was not the issue.  Since that was not the issue I have been trying to figure out the reason behind this

I have a tool I'm developing it consist of a lot of forms which I have under control creating them dynamically.  The deli ma I have
now is that my application lets you update a form  which is a dialog box.  Everything works fine first time  but when I create another element
say a credit card and the user wants to update it  they click the update button and a dialog box pops up then you can make your changes
it works the first time but not after that.  I know its something with the form name which needs to be unique for each form as well as the id
I have a counter for the id tried to do something similar with the name but no luck.  I believe its something about unique name because I
have to call that form again onclick and that doesn't work the second time either

Here is the code
 This is in the main function
function creation {
 var card=  document.creditCardRegister.cardNumber.value;   original form
  des = document.creditCardRegister.description.value;
  var expmonth = document.creditCardRegister.expirationMonth.value;
  var expyear = document.creditCardRegister.expirationYear.value;

*****************Form Creation**********************

var regupdateForm=document.createElement('form'); ="dynamicform";                                                            //This is the culprit it seems
    regupdateForm.setAttribute("id", 'regupdate' +   ++regupdatecounter );    // the counter is global
    regupdateForm.className = "formupdate";

var formbuttonUpdate = document.createElement('button');
    formbuttonUpdate.setAttribute("id", 'updateformbutton');
    formbuttonUpdate.setAttribute("style"," position:absolute; left:295px; top:130px;");
    formbuttonUpdate.type= "submit";
    formbuttonUpdate.innerHTML ="Update";
    alert("what is formupdate cout" + formupdateCounter);
    formbuttonUpdate.onclick = function() {
    alert("Inside form update function"); The second time onclick this is as far as it goes which leads me  to to know its document.dynamicform
                                                                       I tried giving a unique name but still it bombs. I have another function that uses this form name with
                                                                       very same issue second time around
      ************I make it to this function the first time everything works fine*********************************

                                des = document.dynamicform.description.value;
                                alert("updateform where is it breaking");
                                var updateMonth = document.dynamicform.expirationMonth.selectedIndex;
                                alert("form is this working");
                                var getMonth = document.dynamicform.expirationMonth.options[updateMonth].value;
                                alert("Am I getting the month" + getMonth);
                                var updateYear = document.dynamicform.expirationYear.selectedIndex;
                                var getYear= document.getElementById("expirationYear").options[updateYear].value;
                                  alert("Is year part working"+ updateYear);
                                 /**Need to call original form to get card number***/
                                alert("Am I getting card number" + card);
                                var spechar ="/";
                                var monthYear = updateMonth+spechar+getYear;
                                var ccshadow = new String('************', card.length - 4)
                                   + card.substring(card.length - 4);
                                  alert("Am I getting to yeare" + getYear);
                                  var newDescription ="Card Description: ";
                                  nnode.nodeValue =newDescription + des;
                                  var cardNumber ="Card Number:";
                                  var cardExpiration = "Expiration:";
                                  alert("where is it bradking");  
                                  node.nodeValue =cardNumber + ccshadow + " " + cardExpiration + monthYear;
                                                                $("#updateCC" + itemCount).dialog("close");
                                   };  //End of Update Dialog

} // funciton end

I continue to find the solution but I'm reaching out to be guided in the right direction only when I ponder for days

Thanking you in advance This has been a Challenge

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


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