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
documentinterface supports named properties. supported property names @ moment consist of values ofnamecontent attributes ofapplet, exposedembed,form,iframe,img, , exposedobjectelements indocumenthave non-emptynamecontent attributes, , values ofidcontent attributes ofapplet, exposedobjectelements indocumenthave non-emptyidcontent attributes, , values ofidcontent attributes ofimgelements indocumenthave both non-emptynamecontent attributes , non-emptyidcontent 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
namecontent attributea,applet,area,embed,form,frameset,img, ,objectelements in active document have non-emptynamecontent attribute, and- the value of
idcontent attribute of html element in active document non-emptyidcontent 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
Post a Comment