javascript - What this : document.reservation.submit(); is supposed to do? -


i reworking on code of old developer , i'm trying form reservation.

i've looked across whole code thing called reservation name , id of form.

form who's in style : display:none ...

so 2 question in 1 : first of heck supposed

document.reservation.submit(); suppose form name ?

shouldn't document.getelementbyid('reservation').submit() instead ?

and second question : how form can sent if value set display:none tough couldn't work , if want hide them shall use hidden property...

i need bit of on guys pls :)

form beter comprehension :

<form name='reservation' action='http://xxxx/reservationformaction.to' method="post" id="reservation">     <input type="hidden" id="productlive" name="product" value="{$product.info.code}"/>     <input type="hidden" name="complementaryparameters" value=""/>         <input type="text" name="depcitycode" id="depcitycode" style="display:none"  />     <input type="text" name="datedep" id="datedep" style="display:none" />     <input type="text" name="nightduration" id="nightduration"  style="display:none" />     <input type="text" name="dayduration" id="dayduration"  style="display:none" />     <input type="text" name="provider" value="{$product.touroperator.code}" style="display:none" />     <input type="text" id="toproduct" name="tocode" value="{$product.info.toproductcode}" style="display:none" />     <input type="text" name="catalogcode" value="{$product.info.code}" style="display:none" />     {if $ecall}     <input type="text" name="reservationprofilechannelcode" value="ecall" style="display:none" />     {else}     <input type="text" name="reservationprofilechannelcode" value="adv" style="display:none" />     {/if}     <input type="text" name="nbadults" id="nbadults" style="display:none" />     <input type="text" name="nbchildren" id="nbchildren" style="display:none" />     <input type="text" name="nbbabies" id="nbbabies" style="display:none" />     <input type="text" name="producturl" id="producturl" style="display:none" value="http://www.xxxx.com/{$product.slug}_{$product.info.code}.html" />     <input type="text" name="homeurl" id="homeurl" style="display:none" value="http://www.xxxx.com" />     <span id="agechild" style="display:none"></span> <div class="update-search clearfix"> 

document.reservation gets htmlformelement form name reservation. calling submit submits form (without triggering submit event).

so why not document.getelementbyid? also work, document.reservation works because document object gets various properties created on automagically, including properties referring forms name. covered in §3.1.3 of html5 spec *(you have scroll down fair bit):

the document interface supports named properties. supported property names @ moment consist of values of name content attributes of applet, exposed embed, form, iframe, img, , exposed object elements in document have non-empty name content attributes, , values of id content attributes of applet , exposed object elements in document have non-empty id content attributes, , values of id content attributes of img elements in document have both non-empty name content attributes , non-empty id content attributes.

the value of properties element name or id came from.

the window object gets properties every element id, described here:

the supported property names @ moment consist of following, in tree order, ignoring later duplicates:

  • the browsing context name of child browsing context of active document name not empty string,
  • the value of name content attribute a, applet, area, embed, form, frameset, img, , object elements in active document have non-empty name content attribute, and
  • the value of id content attribute of html element in active document non-empty id content attribute.

where again value of properties element name or id came from.

in both cases, html5 specification standardizing previously-widespread-but-nonstandard practice browsers had, used on pages in wild.


how form can sent if value set display:none tough couldn't work , if want hide them shall use hidden property...

it's best ask one question per question.

the css display property has no effect @ on whether form fields submitted; you're thinking of field's disabled state: disabled form fields indeed left out of form on submission.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -