Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Adding innerHTML containing form
Message
De
19/10/2017 04:44:16
 
 
À
18/10/2017 18:02:32
Information générale
Forum:
Javascript
Catégorie:
DHTML
Divers
Thread ID:
01655077
Message ID:
01655082
Vues:
50
>I have a hit which transfers its content into the parent window into a div. Thus, I am using something like loDiv.innerHTML=HTMLCodeFromElsewhere. That HTML contains a form. The form appears ok on the page. However, when typing data into those fields, it is as is nothing was typed. A code like this would show blank values on input fields:
>
>
>function Test()
>{
>   loElements=document.forms['Form1'].elements
>   for (lnCounter=0; lnCounter<loElements.length; lnCounter++)
>   {
>      alert('Name: '+loElements[lnCounter].name+' ID: '+loElements[lnCounter].id+' Value: '+loElements[lnCounter].value)
>   }
>}
>
>
>I have read somewhere that assigning HTML code to the innerHTML approach destroys the contents:
>
>https://stackoverflow.com/questions/2192760/add-to-html-form-without-losing-current-form-input-information-in-javascript
>
>However, in my case, the innerHTML I am passing is the HTML code for the full form. Is that approach supported?

Probably better to use .insertAdjacentHTML() : https://developer.mozilla.org/en-US/docs/Web/API/Element/insertAdjacentHTML
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform