¦^«e­¶

¦b Script ¤¤¶Ç°eªí³æ¡Gform.submit() ¤èªk½d¨Ò

¨S¦³ Submit «ö¶s¤]¯à¶Ç°eªí³æ¸ê®Æ
´¿¸g¦³­Óºô¤Í¦V§Ú°Ý³o­Ó°ÝÃD¡A¥L³]­pªººô­¶¥²¶·¨Ï¥Î FORM ¦V Web Server µn¿ý ÂsÄýªÌ¸ê®Æ¡A¦ý¥Lı±o FORM ªí³æªº SUBMIT «ö¶s¤Ó³æ½Õ¡A¥L·Q¥Î¦Û¤v³]­pªº¹Ï¤ù¥h °µ¬°¶Ç°e±Ò°Ê¶s¡A¤£ª¾¸Ó¦p¦ó°µ¡H²{¦b½Ð§A¥ý¸Õ½d¨Ò¡A§Ú¦A¨Ó¸Ñ»¡¡A½Ð¦b¤U­±ªí³æªº ¤p¹Ï¥Ü«ö¶s¨Ó¶Ç°eªí³æ¸ê®Æ¡C
¹Ï§Î¶Ç°e¶s½d¨Ò
½Ð¿é¤J©m¦W¡G
½Ð¿é¤J¦~ÄÖ¡G

TYPE=IMAGE or submit()
¨ä¹ê­n¥Î¹Ï§Î¨ú¥N Submit «ö¶s¡A³Ì²³æªº¤è¦¡¬O¦bªí³æ¤¤±Ò¥Î TYPE=IMAGE ªº INPUT ¼ÐÅÒ¡A¦p¡G
<INPUT TYPE=IMAGE SRC="¹Ï¤ù URL">
¨º»ò·í§Ú­Ì¥Î·Æ¹««ö³o¼ÐÅҮɡA´N¸ò TYPE=SUBMIT «¬ºAªº INPUT ¤@¼Ë¡A¥i¥H°e¥X ªí³æ¸ê®Æ¡C¦ý¬O³o­Ó«¬ºAªº INPUT ¦b Navigator ¤¤¹ï Script ¤ä´©«×«o«Ü®t¡A¤£¦ý µLªk·Pª¾¥ô¦ó¨Æ¥ó¡A¬Æ¦Ü³s±N·Æ¹«´å¼ÐÂà´«¤â§Îªº¥\¯à³£¨S¦³¡A§¹¥þµLªk´£¿ôÂsÄýªÌ ³o­Ó¹Ï¥Ü¬O­Ó«ö¶s¡C¦Ü©ó Explorer ªº <BUTTON> ¼ÐÅÒ´N¤£´£¤F¡A¦]¬° Navigator ¤£»{±o¡C³o®É§Ú­Ì´N­n±Ä¥Î²Ä¤G­Ó¿ìªk¡A¨º´N¬O¨Ï¥Î form.submit() ¡Aªí³æª«¥ó¶Ç°e¤èªk¡A¥¦ªº¨Ï¥Î¤è¦¡¬O¡G
document.forms.·Q­n¶Ç°eªºªí³æ¦WºÙ.submit();
¦]¦¹¤£ºÞ¬O«ö¶s¡B¹Ï¤ù¡BÁpµ²¡A¥u­n¯à±µ¨üÂsÄýªÌ¨Æ¥ó±Ò°Ê¡A´N¥i¥H¶Ç°eªí³æ¡A¦Ó¤£ºÞ ¦¹±Ò°Ê¼ÐÅÒ¬O§_¬Oªí³æªº¤@³¡¥÷¡C¦Ó¥»½d¨Ò¤¤¡A´N¬O¥Î¤@­Ó LINK ¼ÐÅÒ¥]¦í¤@­Ó IMG Tag ¡AµM«á¥Î onclick ¨Æ¥ó¨Ó¶Ç°eªí³æ¡C
<FORM NAME="myform" METHOD="GET" ACTION="research.htm">

        <!-- ... ¨ä¥L¼ÐÅÒ³]©w ... // -->

        <A HREF="#"
        <!-- ... ¨ä¥L¨Æ¥óªº Script ³]©w ... // -->
         onclick="document.forms.myform.submit();return false;">
        <IMG NAME="img1" SRC="uploada.gif" BORDER="0" WIDTH=80 HEIGHT=50></A>
</FORM>
¦hªí³æªº¿ï¾Ü¶Ç°e

¬JµM formname.submit() ¤èªk¥i¥H§â«ü©wªº form ¶Ç°e¥X¥h¡A¨º»ò¤@­Óºô­¶¤W´N¥i¥H Â\¤@­Ó¥H¤Wªºªí³æ¡AµM«á¥ÑÂsÄýªÌ¨M©w¶Ç°e¨º¤@­Óªí³æ¡A¥H¤ÎÄÝ©ó¤@­Ó form ¤¤ªº submit ¶s¡A¤£¥²¶Ç°e¦Û¤vªº¤÷ªí³æ¡A¦Ó¥i¥H¥hÂà¦Ó¶Ç°eºô­¶¤W¨ä¥Lªí³æ¡CÄ´¦p¤U­±³o­Ó ½d¨Ò¡AÂsÄýªÌ¥i¥H¦Û¦æ¨M©w­n¦¨¬°¤@¯ë·|­û©Îª÷¥d·|­û¡A¦Ó°e¥XÁc²¨âºØ¤£¦Pªºªí³æ ¸ê®Æ¡A§A¥i¥H¤À§O¸Õ¤@¤U¬Ý¬Ý¦^À³ªí³æÅã¥Ü¶Ç°e¸ê®Æªº¤£¦P¡C

¦ó³B¹Ð®J·|­û¸ê®Æµn¿ý
°ò¥»·|­û¸ê®Æ ª÷¥d·|­û¸ê®Æ
¿é¤J©m¦W¡G
©~¦í¦a°Ï¡G
¿é¤J¦~ÄÖ¡G
©Ê        §O¡G ¤k ¨k
½Ð¿é¤J¥N¸¹¡G
½Ð¿é¤J±K½X¡G

­n¤É¯Å¬°ª÷¥d·|­û¶Ü¡H
¬O §_
¤@ºô­¶¦hªí³æ³]­p
¨ä¹ê¾ã­Ó¦ó³B¹Ð®J·|­ûµn¿ý¸ê®Æªí¬O¥Ñ¤T­Ó form °Ï¬q¦@¦Pºc¦¨ªº¡A¥¦­Ì¤À§O¬O¡G
<!-- °ò¥»·|­û¸ê®Æªí // -->
<FORM NAME="membera" METHOD="GET" ACTION="research.htm">
        ¿é¤J©m¦W¡G
        <INPUT TYPE=TEXT NAME="name" SIZE="9" VALUE="Adams Smith"><BR>
        ©~¦í¦a°Ï¡G
        <INPUT TYPE=TEXT NAME="area" SIZE="9" VALUE="Taiwan"><BR>
        ¿é¤J¦~ÄÖ¡G
        <INPUT TYPE=TEXT NAME="age" SIZE="3" VALUE="40"><BR>
        ©Ê        §O¡G
        <INPUT TYPE=RADIO NAME="sex" CHECKED VALUE="female"> ¤k
        <INPUT TYPE=RADIO NAME="sex" VALUE="male"> ¨k
        <INPUT TYPE=HIDDEN NAME="goldden">
</FORM>
<!-- ª÷¥d·|­û¸ê®Æªí // -->
<FORM NAME="memberb" METHOD="GET" ACTION="research.htm">
        <INPUT TYPE=HIDDEN NAME="name">
        <INPUT TYPE=HIDDEN NAME="area">
        <INPUT TYPE=HIDDEN NAME="age">
        <INPUT TYPE=HIDDEN NAME="sex">
        <INPUT TYPE=HIDDEN NAME="goldden">
        ½Ð¿é¤J¥N¸¹¡G
        <INPUT TYPE=TEXT NAME="id" SIZE=8 VALUE="guest"><BR>
        ½Ð¿é¤J±K½X¡G
        <INPUT TYPE=PASSWORD NAME="pass" SIZE=8 VALUE="guest"><BR>
</FORM>
<!-- ¶Ç°e³]©wªí // -->
<FORM NAME="add">
        <BR>­n¤É¯Å¬°ª÷¥d·|­û¶Ü¡H<BR>
        <INPUT TYPE=RADIO NAME="rd1" VALUE="yes"> ¬O
        <INPUT TYPE=RADIO NAME="rd1" CHECKED VALUE="no"> §_<BR>
        <INPUT TYPE=SUBMIT VALUE="¶Ç°eµn¿ý¸ê®Æ" onclick="MultiFormSend();return false;"
</FORM>
¦p¦ó¿ï¾Ü¶Ç°eªí³æ
¥Ñ¤W­±¤T­Ó form ¨Ó¬Ý¡A¬Û«H§A¤£Ãøµoı¡A¹ê»Ú¤W­n¿ï¾Ü¶Ç°eªº¬O form membera ©M form memberb¡A¦Ü©ó form add «h¥u¬O´£¨Ñ¤@­Ó¿ï¾Ü¼ÐÅÒ¡A¥H¤Î¤@­Ó¶Ç°eªí³æ«ö¶s ¦Ó¤w¡A¥»¨­¥¦ªº¸ê®Æ¬O¤£°e¥X¥hªº¡C·í¨Ï¥ÎªÌ¦b form add «ö¤U Submit ¶s«á¡Aonclick ªº Scriipt ³]©w·|Âà¦Ó°õ¦æ¤@­Ó§Ú­Ì³]­pªº MultiFormSend() ¨ç¼Æ¡C¦b³o­Ó¨ç¼Æ¤¤ §Ú­Ì­º¥ý­n§PÂ_ªº´N¬OÂsÄýªÌ¿ï¾Üªº¬O­n¥[¤J¤@¯ë·|­ûÁÙ¬Oª÷¥d·|­û¡H¦]¦¹§Ú­Ì¥i¥H ³o»ò¦w±Æ¡G
function MultiFormSend()
{
    /* ªí³æ forms.add ¤¤ªº Radio ¿ï¶µ rd1 ¡A¬O¨Ñ¨Ï¥ÎªÌ³]©w¬O§_¥[¤Jª÷¥d·|­û
       ªº¿ï¶s¡A©Ò¥H¥ý¨ú¨ä­È¥[¥H§PÂ_­n¶Ç°e¨º­Óªí³æ¡C */
    var sender=document.forms.add;
    var isvip=(sender.rd1[0].checked)?sender.rd1[0].value:sender.rd1[1].value;

    /* ...... ¨ä¥L Script ±Ô­z ...... */
}
§Ú­Ì¦b HTML ùئw±Æ forms.add ªº rd1[0] ­È¬O "yes"¡Ard1[1] ­È¬O "no"¡A¥ÎÅÜ¼Æ isvip ¨ú±o yes or no «á¡A´N¥i¥H¿ï¾Ü­n§â¨º­Ó form submit¡A¨Ò¦p¡G
function MultiFormSend()
{
    /* ...... ¨ä¥L Script ±Ô­z ...... */

    /* ¦pªGÂsÄýªÌ¿ï§_¡A«h¥Î sendform Åܼưѷӷ|­û°ò¥»¸ê®Æªí³æ¡C */
    if (isvip=="no") {var sendform=document.forms.membera;}
    else
    /* ¦pªGÂsÄýªÌ¿ï¬O¡A«h¥Î sendform ÅܼưѷӪ÷¥d·|­û¸ê®Æªí³æ¡C */
    {var sendform=document.forms.memberb;}
    /* §â³Q sendform °Ñ·Ó¨ìªºÅܼƥΠsubmit ¤èªk¡A±q Script ¤¤¶Ç°eªí³æ¡C */
    sendform.submit();
}
ÁÙ¦³¤@ÂI­n´£ªº´N¬O forms.memberb ¤¤¦³¤@°ï TYPE=HIDDEN ªº INPUT ¼ÐÅÒ³]©w¡A ¤Z¬O HIDDEN ªºªí³æ¤¸¥ó¡A³£¬OµLªk¦bºô­¶Åã¥Ü¥X¨Óªº¡A¨º»ò§Ú­Ì¬°¤°»ò°µ³o¼Ëªº ¦w±Æ©O¡H¦]¬°ª÷¥d·|­û©M¤@¯ë·|­û¦b°ò¥»¸ê®Æ¤W¬O¤@¼Ëªº¡A¥u¬Oª÷¥d·|­û¦h¤F id ©M pass ¨â­ÓÄæ¦ì¡A©Ò¥HÁקK¨Ï¥ÎªÌ¿é¤J¨â¦¸¸ê®Æ¡A§Ú­Ì§â©Ò¦³ forms.membera ªº¿é¤J Äæ¦ì¦b forms.memberb ¤¤¥Î HIDDEN ¤]«O¯d¤@¥÷¡A¨ì¨Ï¥ÎªÌ¿ï¾Ü¥[¤Jª÷¥d·|­û®É¡A §Ú­Ì¦b§â°ò¥»·|­ûªº¦U¶µ¿é¤J½Æ»s¨ìª÷¥d·|­ûªº HIDDEN Äæ¦ìùØ¡A³o®É submit ¡A´N ¤£·|¥u°e id ©M pass ¨â­ÓÄæ¦ì¡A¦Ó¬O©Ò¦³°ò¥»·|­ûÄæ¦ì¸ê®Æ¡A¥[¤W id ©M pass ¨â¶µ ¡C¦Ü©ó¨â­Ó form ¤¤¦UÄæ¦ì­Èªº½Æ»s¡A§A¥i¥H¥Î¤U¦C¤è¦¡¡G
    if (isvip=="no") {var sendform=document.forms.membera;}
    else
    /* basic °Ñ·Ó°ò¥»·|­ûªí³æ¡Asendform °Ñ·Óª÷¥d·|­ûªí³æ¡C
       µM«á¤@­Ó¤@­Ó§â¬Û¹ïÀ³Äæ¦ì­È±q membera ½Æ»s¨ì memberb¡C */
    {var basic=document.forms.membera;
     var sendform=document.forms.memberb;
     sendform.name.value=basic.name.value;
     sendform.area.value=basic.area.value;
     sendform.age.value=basic.age.value;
     sendform.sex.value=(basic.sex[0].checked)?basic.sex[0].value:basic.sex[1].value;}
¦n¤F¡A¸g¹L³o¼ËÅé¶Kªº³]­p¡A¬J¤£·|¦³ªí³æÂø¶Ãªº·Pı(¨Æ¹ê¤WÂsÄýªÌ³£·|¿ùı¥L¥u¦b ¾Þ§@¤@­Óªí³æ¦Ó¤w)¡A¦Ó¥BÂsÄýªÌ¬Ù¤U­«Âпé¤J°Ê§@¡A§Aªº Web Server ¤]µ·²@¨Sº|±¼ ¥²­nªº°T®§¡C©Ò¥H¥Î Script ¾Þ§@ form.submit() ¡A¥i¤£¥u¥\¥Î¤@ÂIÂI³á¡C

¦^«e­¶
1