SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2007
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to set/send several html variables?

    Code:
    <form name="input" action="mypage.php" method="POST">
    <input type="hidden" name="page" value="main" />
    <input type="hidden" name="action" value="insert" />
    
    First name: <input type="text" name="firstname"/>
    <br>
    Last name: <input type="text" name="lastname"/>
    <input type="button" value="Send" onclick="setPageAction( 'main', 'insert' )" />
    </form>
    In a page, I have the page and action variables set. This is read in my app, and the front controller determins the correct php page to handle the request.

    The above form works well.

    BUT

    On a web page I will often have several links, forms, etc that should be able to modify page and action, on top of other variables that is spesific to the form etc.

    Code:
    function setPageAction( page, action )
    {		
    	document.input.page.value=page
    	document.input.action.value=action
    	document.input.submit()
    	return false
    }
    I use a javascript like this on onclick="setpageaction( main, insert )" on the form button. But this only work for the form named "input". How should I modify this so that it work with any form, or link?

    PS: There might be several variables to be set like large forms + action + page + sessionid + variables to set if cookie is diabled etc...

    PSS: Preferably send all this with "POST" and not in url with "GET".
    Last edited by darkslayer; Dec 6, 2007 at 03:40.

  2. #2
    SitePoint Enthusiast
    Join Date
    Nov 2007
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ... no replies...

    Either I ask a question you ppl don't understand, or you have never had this kinda problem.

    Pls let me know so I can better refrase myself if needed.


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
  •