SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist
    Join Date
    Jul 2004
    Location
    USA
    Posts
    594
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    form.submit() Problem

    Hey,

    Im trying to make a form submit automatically but im running into problems.

    If i actually click the Submit button it works perfectly, but when i add in the javascript to submit it, it goes to the page but acts like it didnt take the values, nothing happens.

    Code:
    <form name="myform" action="*removed*" method="post">
    
    			<TABLE class=table_lines cellSpacing=0 cellPadding=6 width="100%"	border=0>
    			<TBODY>
    				<TR>
    					<TH colSpan=4>Buy Weapons</TH>
    				</TR>
    
    			<TR>
    				<TH class=subh align=left>Attack Weapons</Th> 
    				<TH class=subh align=right>Strength</Th> 
    				<TH class=subh align=right>Price</Th> 
    				<TH class=subh>Buy</Th>
    			</TR>
    			   <TR><TD>Tooth Knife</TD>			  <TD align=right>5</TD>
    			  <TD align=right>1,000 Gold</TD>
    			  <TD align=middle><INPUT size=3 value=0 name=buy_w0></TD></TR><TR><TD>Wicked Dagger</TD>			  <TD align=right>10</TD>
    			  <TD align=right>1,800 Gold</TD>
    			  <TD align=middle><INPUT size=3 value=0 name=buy_w1></TD></TR><TR><TD>Brass Short Sword</TD>			  <TD align=right>20</TD>
    			  <TD align=right>3,200 Gold</TD>
    			  <TD align=middle><INPUT size=3 value=0 name=buy_w2></TD></TR><TR><TD>Imperial Blade</TD>			  <TD align=right>40</TD>
    			  <TD align=right>5,100 Gold</TD>
    			  <TD align=middle><INPUT size=3 value=0 name=buy_w3></TD></TR><TR><TD>Flaming Whip</TD>			  <TD align=right>160</TD>
    			  <TD align=right>16,400 Gold</TD>
    			  <TD align=middle><INPUT size=3 value=0 name=buy_w4></TD></TR><TR><TD>Frozen Sword</TD>			  <TD align=right>640</TD>
    			  <TD align=right>52,400 Gold</TD>
    			  <TD align=middle><INPUT size=3 value=0 name=buy_w5></TD></TR><TR><TD>Lightning Blade</TD>			  <TD align=right>2,560</TD>
    			  <TD align=right>200,000 Gold</TD>
    			  <TD align=middle><INPUT size=3 value=0 name=buy_w6></TD></TR><TR><TD>Magical Katana</TD>			  <TD align=right>10,000</TD>
    			  <TD align=right>750,000 Gold</TD>
    			  <TD align=middle><INPUT size=3 value=0 name=buy_w7></TD></TR><TR><TD>Head Smasher</TD>			  <TD align=right>21,000</TD>
    			  <TD align=right>1,500,000 Gold</TD>
    			  <TD align=middle><INPUT size=3 value=0 name=buy_w8></TD></TR>			  <TR>
    			    <TH class=subh align=left>Defense Weapons</Th> 
    			    <TH class=subh align=right>Strength</Th> 
    			    <TH class=subh align=right>Price</Th> 
    			    <TH class=subh>Buy</Th></TR>
    			  <TR><TD>Adaman Vest</TD>			  <TD align=right>10</TD>
    			  <TD align=right>1,800 Gold</TD>
    			  <TD align=middle><INPUT size=3 value=0 name=buy_dw0></TD></TR><TR><TD>Aegis Shield</TD>			  <TD align=right>20</TD>
    			  <TD align=right>3,200 Gold</TD>
    			  <TD align=middle><INPUT size=3 value=0 name=buy_dw1></TD></TR><TR><TD>Mythril Armlet</TD>			  <TD align=right>40</TD>
    			  <TD align=right>5,100 Gold</TD>
    			  <TD align=middle><INPUT size=3 value=0 name=buy_dw2></TD></TR><TR><TD>Dragon Armor</TD>			  <TD align=right>160</TD>
    			  <TD align=right>16,400 Gold</TD>
    			  <TD align=middle><INPUT size=3 value=0 name=buy_dw3></TD></TR><TR><TD>Mirror Force</TD>			  <TD align=right>640</TD>
    			  <TD align=right>52,400 Gold</TD>
    			  <TD align=middle><INPUT size=3 value=0 name=buy_dw4></TD></TR><TR><TD>Gaia Gear</TD>			  <TD align=right>2,560</TD>
    			  <TD align=right>200,000 Gold</TD>
    			  <TD align=middle><INPUT size=3 value=0 name=buy_dw5></TD></TR><TR><TD>Flame Armor</TD>			  <TD align=right>10,000</TD>
    			  <TD align=right>750,000 Gold</TD>
    			  <TD align=middle><INPUT size=3 value=0 name=buy_dw6></TD></TR><TR><TD>Unbreakable Shield</TD>			  <TD align=right>21,000</TD>
    			  <TD align=right>1,500,000 Gold</TD>
    			  <TD align=middle><INPUT size=3 value=2 name=buy_dw7></TD></TR>			  <TR>
    			    <TD align=middle colSpan=5><INPUT type=submit value="Process Order" name=buybut3></TD></TR>
    			</TBODY></TABLE></form>
    
      </CENTER>      </TD>
        </TR></TBODY></TABLE>
        
            <SCRIPT language="JavaScript">
    
    		
     document.myform.submit();
     
    		
    
                </SCRIPT>
    Can anyone offer any help?
    BKerr

  2. #2
    SitePoint Addict jtrelfa's Avatar
    Join Date
    Oct 2004
    Location
    Troy, Mi
    Posts
    231
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try one of two things:

    1. Give your form an id ("myform" for example) and try document.getElementById('myform').submit();

    2. Try using the forms collection: document.forms["myform"].submit();


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •