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 ofname
content attributes ofapplet
, exposedembed
,form
,iframe
,img
, , exposedobject
elements indocument
have non-emptyname
content attributes, , values ofid
content attributes ofapplet
, exposedobject
elements indocument
have non-emptyid
content attributes, , values ofid
content attributes ofimg
elements indocument
have both non-emptyname
content attributes , non-emptyid
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 attributea
,applet
,area
,embed
,form
,frameset
,img
, ,object
elements in active document have non-emptyname
content attribute, and- the value of
id
content attribute of html element in active document non-emptyid
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
Post a Comment