#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Stratford-upon-Avon, UK
    Posts
    66
    Rep Power
    12

    2 forms to submit using one (CSS) button


    Hi All (my first post here),

    I've got a page with a form on, and a separate hidden form with an 'action' variable in (this is much shortened version!):

    PHP Code:
    <FORM NAME="pageEditForm" METHOD="post">
    <
    INPUT NAME="pagename" type="text" size="20" maxlength="20" value="main">
    </
    FORM
    Another form is hidden:

    PHP Code:
    <FORM NAME="hiddendiscardpageform" METHOD="post">
    <
    INPUT NAME="action" TYPE="hidden" VALUE="discard">
    </
    FORM
    The code for the button is:

    PHP Code:
    <DIV CLASS="BJ_menuElement"
     
    onclick="javascript:document.hiddendiscardpageform.submit();document.pageEditForm.submit();"
     
    onmouseout="this.className='BJ_menuElement';"
     
    onmouseover="this.style.cursor='pointer';this.className='BJ_menuElementHover';">
    <
    CENTER>Discard Changes</CENTER></DIV
    Submitting one page is OK in the 'onclick', but the above sends only the last page in the list.

    Reading on earlier posts, it seems one solution (acceptable to me if I can get it to work) is to post the 'action' from 'hiddendiscardpageform' to 'pageEditForm'.

    Why a CSS button, instead of a normal submit button? The whole site uses these (menu's, etc), so it's in keeping with the theme.

    Why not just put the action bit in the other form? Because there are five buttons on the page with different actions, but all send the information from the pageEditForm.

    What do I need to change to get this to work? Any help would be MUCH appreciated, as I have been stuck on this for weeks, and despite trawling the web, can't find the answer (or more likely I'm too simple to see it ).




    Trevor
    "Good artists copy, great artists steal." Pablo Picasso
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Stratford-upon-Avon, UK
    Posts
    66
    Rep Power
    12
    Hi

    Well, as someone said, 'the silence was deafening'!

    I eventually figured it out. Instead of the button doing the submit, make it go to a javascript function. In that function, make the hidden values in one form equal those in the other, and then submit the form.

    In my case, I did away with most of the hidden forms and used javascript variables instead.





    Trevor
    "Good artists copy, great artists steal." Pablo Picasso

IMN logo majestic logo threadwatch logo seochat tools logo