how can i submit a form without clickin on a submit button?

Discussion in 'OT Technology' started by driftwell, Sep 24, 2004.

  1. driftwell

    driftwell New Member

    Joined:
    Oct 7, 2003
    Messages:
    220
    Likes Received:
    0
    right now i've got pictures that sends out a variable called 'bid'and a hidden form on the same page with a variable called 'page'

    how can i send the form when i click on any of the pictures? I can only get one or the other variable to pass, but not both

    code on page 1:
    <table>
    <td valign=top width=95>
    <a href="banners_edit_db.asp?bid=<%=rsBanners.fields("banner_name")%>"><img src="../images/<%=server.urlencode(rsBanners.fields("banner_name"))%>.jpg" onClick="javascript:formsubmit(); return false;"></a></td>
    </table>

    <script language="JavaScript1.2">

    function formsubmit()
    {
    fm.action.value="clearPager.do?action=clearPager";
    fm.submit()
    return true;
    }
    </script>

    <form name="fm" action="banners_edit_DB.asp" method=get>


    <input type=hidden name="page" value="<%=page%>">


    </form>

    the code on page 2 is merely:

    bid=request.querystring("bid")
    page=request.querystring("page")
     
  2. Keyzs

    Keyzs OT Supporter

    Joined:
    Nov 3, 2003
    Messages:
    814
    Likes Received:
    0
    Location:
    Charlotte, MI
    Your code does not make much sense... Why are you trying to submit the form if all the fields are hidden on using a GET. Just put all the variables you want to pass in the link.

    Code:
    <table>
    	<td valign=top width=95>
    		<a href="banners_edit_db.asp?action=clearPager&bid=<%=rsBanners.fields("banner_name")%>&page=<%=page%>">
    			<img src="../images/<%=server.urlencode(rsBanners.fields("banner_name"))%>.jpg">
    		</a>
    	</td>
    </table>
    
     
  3. driftwell

    driftwell New Member

    Joined:
    Oct 7, 2003
    Messages:
    220
    Likes Received:
    0
    oh sweet... haha i'm new to all of this... doing it for a senior project... and i'm one of those instances that didn't learn much in class until now where i had to apply it.

    Thank you so much... been stuck on this for days. I didn't know you can pass more than one variable through querystring.

    Quick question... what is the purpose of the "action=clearPager" do?

    thanks again man
     
  4. Keyzs

    Keyzs OT Supporter

    Joined:
    Nov 3, 2003
    Messages:
    814
    Likes Received:
    0
    Location:
    Charlotte, MI
    You can as many name/value pairs as you want, there is a length limit but I cannot remember how many charactors that is... Just seperate them with a &.

    I haven't a clue what the purpose is, I just took all the possible querystrings in the code you listed. The ACTION property of the form would have been changed by the JAVAscript you have used to include that name value pair. If you do not need it, jsut delete it.

    Another note you might want to URLEncode the fields in the Querystring.

    And one more suggestion 'banners_edit_db.asp' is a crappy name for a file. Underscores may cause problems or confusion in a URL...

    The code changed a little to look better on the page.
    Code:
    <%
    strBannerName = server.urlencode(rsBanners.fields("banner_name"))
    strPage = server.urlencode(page)
    %>
    
    <a href="BannersEditDB.asp?&bid=<%= strBannerName%>&page=<%= strPage%>">
    	<img src="../images/<%= strBannerName%>.jpg">
    </a>
    
     
    Last edited: Sep 26, 2004

Share This Page