JavaScript Problem Updating Dynamically Created Form

Tuesday, November 26, 2013

0 comments
Hello


I have been pondering with this issue for a while.  I leave it and work around it but still have to come back to it  to get it working. 


I am dynamically creating CC which works fine each CC created give you an option to update the CC or delete it which either
when click on the button give you a popup dialog box in which you can delete or update.  I'm having an issue with the update.

When I try to update the first CC created it will update but if I try to update it again or any other CC created after it gives
me the information from the first update.  I have tried giving the form different names using an array I have given unique ids
and still I get the same result information from the first card updated for every card I try to update.  I can't figure out
what else I can do.  If I stepping on something or what.  Code sample below The update should allow a user to update
the card description and the month and year of expiration of card

 var itemCount = 0; //global variable
  var formupdateCounter = 0;
  var ccsummaryCount =0;
  var btnCount = 0;
  var regupdatecounter =0;
  var newccCount = 0;
  var nnextDivCounter = 0;
  var descCount = 0;
  var newdiv = 0;
  var submit =0;
  var confirm = 0;
  var thisForm = 0;
  var dialog = 0;
  var exp =0;
function registerCreditCard(){
 
 
  alert("Is it getting here");
 


 /********This code should do some DOM creatiaon of elements capturing imformation from
          form to add to My Credit Cards tab*******************************************/
    
  var card=  document.creditCardRegister.cardNumber.value;
  des = document.creditCardRegister.description.value;
  var expmonth = document.creditCardRegister.expirationMonth.value;
  var expyear = document.creditCardRegister.expirationYear.value;
  var spechar ="/";
  var monthyear = expmonth+spechar+expyear;
  var cshadow = new String('************', card.length - 4)
                  + card.substring(card.length - 4);
 /*This grabs all of the info from the form(creditCardRegister)*/

 
 
//This is for My Credit Cards Tab
 var element = document.getElementById("creditCards");                     
 

 var parent= element.parentNode;
 



var node=document.createTextNode("Card Number:" +cshadow+ " " + "Expiration:" + monthyear);

  var para2 = document.createElement("p");
  para2.id ="paragraph2";
  para2.style.position="relative";
  para2.style.left= "-10px";
 
  var nnode = document.createTextNode("Card Description:"  + des);
 
 
 
 //Create button Dynamic
 
 
   var button = document.createElement("button");
    button.setAttribute("id", 'btn' + ++btnCount);
    //button.id ="btn";      //need a counter
    button.className ="ui-button ui-widget ui-state-default ui-corner-all ui-state-hover ui-button-text-only";
    button.innerHTML ="Update";
    button.onclick = function() {                      // Note this is a function   Calling function updatebutton
        alert("creating form and dialog"); 
     
       
 /**************Create Update Form******************/
 
 
  var element2 = document.getElementById("creditCards");   
  
  
   var parent2= element2.parentNode;
 
    
     itemCount += 1;
     
    alert("What is the count Now" + itemCount);
   
    var newElement = document.createElement('div');
    newElement.setAttribute("id", 'updateCC' + itemCount);   
    newElement.setAttribute("style","display:none;");
  
      alert("Debugging");
      alert(" Trying to see What is the count Now" + itemCount);
  
    
    var nextDiv = document.createElement('div');
    nextDiv.className ="dialogWrapper";
    nextDiv.setAttribute("id", 'updateCCDialog' + ++dialog);
   
 
    alert("Appending Divs");
    var dynamicforms = new Array("dynamic1","dynamic2","dynamic3","dynamic4");
   
    var regupdateForm=document.createElement('form');
    regupdateForm.name =  "dynamicforms[thisForm]";
    regupdateForm.setAttribute("id", 'regupdate' ); 
    regupdateForm.className = "formupdate";
    regupdateForm.method='';
    regupdateForm.action='';

  
    alert("Start of form name creation count" + dynamicforms[thisForm]);
   
     var newdes = " ";
    var form_Msg = document.createElement('p');
    var msg_Node =document.createTextNode("Are you sure you want to update this card?");
   
   
    var firstInput = document.createElement('input');
    firstInput.setAttribute("id", 'comfirmupdate' + confirm);
    firstInput.name = "description";
    firstInput.setAttribute("value", newdes);
    alert("Trying to see what is des" + newdes);
    firstInput.setAttribute("style"," position:absolute; left:150px; top:30px;");
    firstInput.value =newdes;//getvalue from document.creditCardRegister.description.value;
    firstInput.type ="text";
    firstInput.required ="true";
   
    var formLabel =document.createElement('label');
    formLabel.setAttribute("for", description);
    formLabel.innerHTML = "* Card Description: ";
    formLabel.setAttribute("style"," position:absolute; left:18px; top:37px;");
      
  
   
    newElement.appendChild(nextDiv); 
    form_Msg.appendChild(msg_Node);
    form_Msg.appendChild(firstInput);
    form_Msg.appendChild(formLabel)
    regupdateForm.appendChild(form_Msg);
   
      alert("Start of form creation 0");
   
      
  
    alert("Is this append working for formInput");
   
    var nextLabel=document.createElement('label');
    nextLabel.innerHTML = "* Expiration: ";
    nextLabel.setAttribute("style"," position:absolute; left:18px; top:65px;");
   
     regupdateForm.appendChild(nextLabel);
   
   
    var month = new Array("January","Februray","March","April","May","June","July","August","September","October","November","December")
    var selectMonth =  document.createElement('select');
    selectMonth.name= "expirationMonth";
    //selectMonth.id = "expirationMonth";
    selectMonth.setAttribute("id", 'expirationMonth' + ++exp);
    selectMonth.className = "expirationMonth";
    selectMonth.setAttribute("style"," width:80px; position:absolute; top:65px; left:150px;");
     for(var i=0;i<month.length;i++)
      {
          var mt = i;
          mt = document.createElement('option');
          mt.text=month[i];
          mt.id="expMonth";
          mt.name="month";
          mt.value=month[i];
          selectMonth.appendChild(mt);
      }
     
   
     regupdateForm.appendChild(selectMonth);
     
  var selectYear = document.createElement('select');
      selectYear.name="expirationYear";
      selectYear.id="expirationYear";
      selectYear.name="expirationYear";
      selectYear.setAttribute("style"," width:80px; position:absolute; top:65px; left:240px;");
       for(var i=2013; i<=2024; i++)
        {
          var yr = i;
          yr = document.createElement('option');
          yr.text=i;
          yr.name="year";
          yr.value=yr;
          selectYear.appendChild(yr);
        }
     
   
      regupdateForm.appendChild(selectMonth);
      regupdateForm.appendChild(selectYear);
      newElement.appendChild(regupdateForm);
   
    alert("Start of form creation2");
   
   
    alert("Start of form creation3");
   
   
    var nnextDiv = document.createElement('div');
    nnextDiv.className ="UpdateCreditCardActions";
    nnextDiv.setAttribute("id", 'updatecc' +  ++newdiv);
     var formbuttonUpdate = document.createElement('button');
    formbuttonUpdate.setAttribute("id", 'updateformbutton');
    formbuttonUpdate.setAttribute("style"," position:absolute; left:295px; top:130px;");
    formbuttonUpdate.type= "submit";
    formbuttonUpdate.innerHTML ="Update";
  
    formbuttonUpdate.onclick = function() {
 
    alert("Inside form update function");
   
           
                                var newdes = document.forms['dynamicforms[thisForm]' ].description.value;
                                                            
                                alert("Inside update form what form name" + dynamicforms[thisForm]);
                              
                                                                                                                                                                                      *****************This function is where I'm running into my issue I continue to get same information
                                                                                                                                                                                                                    from first update*****************************************
                               
                                alert("Inside formupdate what is description" + newdes);
                                var updateMonth = document.forms['dynamicforms[thisForm]'].expirationMonth.selectedIndex;
                                alert("form is this working");
                              
                                var getMonth = document.forms['dynamicforms[thisForm]'].expirationMonth.options[updateMonth].value;
                                alert("Am I getting the month" + getMonth);
                               
                                                             
                                var updateYear = document.forms['dynamicforms[thisForm]'].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 monthYear2 = 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 + newdes;
                                
                                  var cardNumber ="Card Number:";
                                  var cardExpiration = "Expiration:";
                                  alert("where is it bradking");  
                                  node.nodeValue =cardNumber + ccshadow + " " + cardExpiration + monthYear2;
                                                                  
                                  $("#updateCC" + itemCount).dialog("close");
                                   alert("Is counter working in update" +  itemCount);
                            
                                       
                                        //alert("trying to seet what is array name" + dynamicforms[a]);
                                   
                                        confirm +=1;                      
                                        regupdatecounter +=1;
                                       thisForm += 1;
                                       a +=1;
                                   
                                   };  //End of Update Dialog
   
 
********************There is more code to this huge function but not relevent*********************************************  .
}


I would really appreciate your help I traced through it until 3 am this morning nothing I tried works:(  I need another set of eyes


Thank You In Advance

PH

--
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 javascript-information+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

surprise Market

Thursday, November 21, 2013

0 comments

 

 

traditional clothes

 

3abaya chaymae 1

3abaya chaymae 2

3abaya chaymae 3

3abaya chaymae 4

3abaya chaymae 5

3abaya chaymae 6

3abaya chaymae 7

 

www.aswaq-tetouan.com

 

Woman Shoes

Women's leather shoes

Boots black leather

Shoes with platform

Brown crocodile shoes

Burgundy boots 

Boots caramel color

Crocodile brown boots

Brown crocodile shoes

Daim boots

Daim shoes

Brown Women Boots

Gray leather boots

Boots gray microfiber

 

www.aswaq-tetouan.com

 

Women Bag

Brown crocodile bag

colorful leather

Daim bag

Brown bag

 

www.aswaq-tetouan.com

 

watches

for woman1

for women2

for women3

for men1

for men2

for men3

 

www.aswaq-tetouan.com

 

Perfumes and Makeup

Blush perfume

Cocolay Perfume

Feelings perfume

Ocean Blue perfume

Tycoon Perfume

Oriflame Perfume

Corp cream

Black Mascara 

Anti-Acne

 Flamboyant Perfumes

Brightening Powder

 

www.aswaq-tetouan.com

Site Aswaq Tetouan ,the first electronic Market for Tetouan city sellers.

Publish all the new in the market of merchandise , prices  , offers and discounts.

Which we communicate with our customers  in all part of Morocco and the world to give yours the opportunity to shop from your home or through your phone

 

email : aswaqtetouan@gmail.com     

 

 

 

--
You received this message because you are subscribed to the Google Groups "Website Design Nz" group.
To unsubscribe from this group and stop receiving emails from it, send an email to website-design-nz+unsubscribe@googlegroups.com.
To post to this group, send email to website-design-nz@googlegroups.com.
Visit this group at http://groups.google.com/group/website-design-nz.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Sort problem

Wednesday, November 20, 2013

0 comments
Thanks a lot. It works =D 

On Thursday, November 21, 2013 4:25:47 AM UTC+8, Binary Tutor wrote:
function sortLeftlist() {
    var lb = document.getElementById('JWP_UIWT_swapper1_leftSelect');
    var itemList = [];
    
    for(i=0; i<lb.options.length; i++)
        itemList[i] = {text:lb.options[i].text, title:lb.options[i].title};
    
    itemList.sort(function(a, b) {
        return a.text < b.text ? -1 : a.text == b.text ? 0 : 1; 
    });
    
    for(i=0; i<itemList.length; i++)  {
        lb.options[i].text = lb.options[i].value = itemList[i].text;
        lb.options[i].title = itemList[i].title;
    }
}

While I have scanned the above code most carefully, I don't have the infrastructure to test it before sending it to you.

Good luck.

On Wednesday, November 20, 2013 2:12:34 AM UTC-5, Sia wrote:
Hi, I have 2 listboxes (Items can moves between them) and i need to display the text description/title for each item when mouse over. How do i sort the description/title according to thier item after the item moved.

I have set the moved item located at the bottom of the list first. Then i will sort them after that. However i do not know how to sort the mouse over description/title according to their items.
Remind : Description/title must tie to its item. 

Please help. Thanks.

function JWP_UIWT_swap(inSrc, inAll) {
    if (inSrc == JWP_UIWT_LEFT) {
      oSrc = document.getElementById("JWP_UIWT_swapper1_leftSelect");
      oDest = document.getElementById("JWP_UIWT_swapper1_rightSelect");
      
    } else {
      oSrc = document.getElementById("JWP_UIWT_swapper1_rightSelect");
      oDest = document.getElementById("JWP_UIWT_swapper1_leftSelect");
      
    }
    
    for (i = 0; i < oSrc.options.length; i++) {
      oOpt = oSrc.options[i];
      if (oOpt.selected || inAll) {
      oNew = new Option(oOpt.text , oOpt.value);
      oNew.title = oOpt.title;
      oDest.options[oDest.options.length] = oNew;
        oSrc.remove(i);
        i--;
        
      }     
    }
  }

   function sortLeftlist() {
var lb = document.getElementById('JWP_UIWT_swapper1_leftSelect');
arrTexts = new Array();
arrTitle = new Array();

for(i=0; i<lb.length; i++)  {
 arrTexts[i] = lb.options[i].text;
 arrTitle[i] = lb.options[i].title;
}

arrTexts.sort();

for(i=0; i<lb.length; i++)  {
 lb.options[i].text = arrTexts[i];
 lb.options[i].value = arrTexts[i];
 lb.options[i].title = arrTitle[i];
}
}

--
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 javascript-information+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Sort problem

0 comments
function sortLeftlist() {
    var lb = document.getElementById('JWP_UIWT_swapper1_leftSelect');
    var itemList = [];
    
    for(i=0; i<lb.options.length; i++)
        itemList[i] = {text:lb.options[i].text, title:lb.options[i].title};
    
    itemList.sort(function(a, b) {
        return a.text < b.text ? -1 : a.text == b.text ? 0 : 1; 
    });
    
    for(i=0; i<itemList.length; i++)  {
        lb.options[i].text = lb.options[i].value = itemList[i].text;
        lb.options[i].title = itemList[i].title;
    }
}

While I have scanned the above code most carefully, I don't have the infrastructure to test it before sending it to you.

Good luck.

On Wednesday, November 20, 2013 2:12:34 AM UTC-5, Sia wrote:
Hi, I have 2 listboxes (Items can moves between them) and i need to display the text description/title for each item when mouse over. How do i sort the description/title according to thier item after the item moved.

I have set the moved item located at the bottom of the list first. Then i will sort them after that. However i do not know how to sort the mouse over description/title according to their items.
Remind : Description/title must tie to its item. 

Please help. Thanks.

function JWP_UIWT_swap(inSrc, inAll) {
    if (inSrc == JWP_UIWT_LEFT) {
      oSrc = document.getElementById("JWP_UIWT_swapper1_leftSelect");
      oDest = document.getElementById("JWP_UIWT_swapper1_rightSelect");
      
    } else {
      oSrc = document.getElementById("JWP_UIWT_swapper1_rightSelect");
      oDest = document.getElementById("JWP_UIWT_swapper1_leftSelect");
      
    }
    
    for (i = 0; i < oSrc.options.length; i++) {
      oOpt = oSrc.options[i];
      if (oOpt.selected || inAll) {
      oNew = new Option(oOpt.text , oOpt.value);
      oNew.title = oOpt.title;
      oDest.options[oDest.options.length] = oNew;
        oSrc.remove(i);
        i--;
        
      }     
    }
  }

   function sortLeftlist() {
var lb = document.getElementById('JWP_UIWT_swapper1_leftSelect');
arrTexts = new Array();
arrTitle = new Array();

for(i=0; i<lb.length; i++)  {
 arrTexts[i] = lb.options[i].text;
 arrTitle[i] = lb.options[i].title;
}

arrTexts.sort();

for(i=0; i<lb.length; i++)  {
 lb.options[i].text = arrTexts[i];
 lb.options[i].value = arrTexts[i];
 lb.options[i].title = arrTitle[i];
}
}

--
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 javascript-information+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Sort problem

Tuesday, November 19, 2013

0 comments
Hi, I have 2 listboxes (Items can moves between them) and i need to display the text description/title for each item when mouse over. How do i sort the description/title according to thier item after the item moved.

I have set the moved item located at the bottom of the list first. Then i will sort them after that. However i do not know how to sort the mouse over description/title according to their items.
Remind : Description/title must tie to its item. 

Please help. Thanks.

function JWP_UIWT_swap(inSrc, inAll) {
    if (inSrc == JWP_UIWT_LEFT) {
      oSrc = document.getElementById("JWP_UIWT_swapper1_leftSelect");
      oDest = document.getElementById("JWP_UIWT_swapper1_rightSelect");
      
    } else {
      oSrc = document.getElementById("JWP_UIWT_swapper1_rightSelect");
      oDest = document.getElementById("JWP_UIWT_swapper1_leftSelect");
      
    }
    
    for (i = 0; i < oSrc.options.length; i++) {
      oOpt = oSrc.options[i];
      if (oOpt.selected || inAll) {
      oNew = new Option(oOpt.text , oOpt.value);
      oNew.title = oOpt.title;
      oDest.options[oDest.options.length] = oNew;
        oSrc.remove(i);
        i--;
        
      }     
    }
  }

   function sortLeftlist() {
var lb = document.getElementById('JWP_UIWT_swapper1_leftSelect');
arrTexts = new Array();
arrTitle = new Array();

for(i=0; i<lb.length; i++)  {
 arrTexts[i] = lb.options[i].text;
 arrTitle[i] = lb.options[i].title;
}

arrTexts.sort();

for(i=0; i<lb.length; i++)  {
 lb.options[i].text = arrTexts[i];
 lb.options[i].value = arrTexts[i];
 lb.options[i].title = arrTitle[i];
}
}

--
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 javascript-information+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

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

Monday, November 18, 2013

0 comments
Hello:



It is considered a standard for an array of forms.



PH

On Friday, November 15, 2013 1:49:37 AM UTC-6, pame...@aol.com wrote:
Hello:



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
behavior:


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');
    regupdateForm.name ="dynamicform";                                                            //This is the culprit it seems
    regupdateForm.setAttribute("id", 'regupdate' +   ++regupdatecounter );    // the counter is global
    regupdateForm.className = "formupdate";
    regupdateForm.method='';
    regupdateForm.action='';



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
PH
   
    

--
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 javascript-information+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

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