Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Grabbing fields from another form to post in current form
Message
De
17/03/2015 14:19:58
 
 
À
Tous
Information générale
Forum:
Javascript
Catégorie:
Autre
Titre:
Grabbing fields from another form to post in current form
Divers
Thread ID:
01616906
Message ID:
01616906
Vues:
30
This is for sharing purposes.

This allows a form in page to grab some fields from another post to include in the current post:
function MyFunction()
{
   ...
   loFormElement=document.Form1.elements
   lnElement=loFormElement.length
   for (lnCounter=0;lnCounter<lnElement;lnCounter++)
   {
      loElement=loFormElement[lnCounter]
      if (loElement.tagName=='INPUT')
      {
         if (loElement.type=='text')
         {
            loNewElement=loElement.cloneNode(true)
            loNewElement.type='hidden'
            loElementToFind=document.LXDataEntry.elements.namedItem(loElement.name)
            if (loElementToFind)
            {
               loElementToFind.parentNode.removeChild(loElementToFind)
            }
            document.LXDataEntry.appendChild(loNewElement)
         }
      }
      if (loElement.tagName=='SELECT')
      {
         loNewElement=document.createElement('input')
         loNewElement.type='hidden'
         loNewElement.name=loElement.name
         loNewElement.value=loElement.value
         loElementToFind=document.LXDataEntry.elements.namedItem(loElement.name)
         if (loElementToFind)
         {
               loElementToFind.parentNode.removeChild(loElementToFind)
         }
         document.LXDataEntry.appendChild(loNewElement)
      }
   }
   document.LXDataEntry.submit()
}
This takes all input fields as well as all select fields from Form1 and clone them into LXDataEntry form before the submit.

I also take only the input type text and change them into hidden fields to be posted in LXDataEntry. The same applies to the select. This avoid duplicating those fields as is in the bottom of the page and submit them transparently.

I also have support for removing those cloned fields before adding them. This is in case the page can post multiple times in order to avoid duplicate fields.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Répondre
Fil
Voir

Click here to load this message in the networking platform