SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Oct 2009
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Red face Stupid form submission question...

    I'm wokring on a simple franken problem, and they are the worst. I'm not sure if this is JavaScript, PHP, or the dreaded combination. When I did a search on the net this combo thing pops up a lot of confusing AJAX repsonses.

    The problem has two parts. I have a form element (pull down, form select, actually) that I want to submit with an "onChange" event. (Frequently I use JavaScript as a client side validator when filling out a form.)

    The second part is the page is dynamically generated php content. A $_GET variable is sent to a controller script to indicate the status of the page as it reloads. The form select is passed in the $_POST variable (a value that alters the php presentation of the content). The form content is sent with the submission of the form, but how do I send the $_GET variable. In PHP it is a "send header" function.
    -------------------------------------------------------
    Lenono W500/Archlinux
    Local: IBM x225/CentOS 6.5
    Remote: Hostnine.com

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,863
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    To send $_GET values from JavaScript you add the information into location.search

    The alternative and more common way in JavaScript is to just append the value after the ? in the URL you are setting up.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    SitePoint Zealot
    Join Date
    Oct 2009
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good. If I want to have a form submit its $_POST variables from it's select element when the onChange event is triggered, put a JavaScript function in the onChange event handler. This calls a function in the header. The function sets the url variable (equivalent of the $_GET variable) as mentioned and then submit the form with submit(), and close the header function!
    Whew! I'll try it... Thanks
    -------------------------------------------------------
    Lenono W500/Archlinux
    Local: IBM x225/CentOS 6.5
    Remote: Hostnine.com

  4. #4
    SitePoint Zealot
    Join Date
    Oct 2009
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is not working out right now. I'm getting a header conflict. To move ahead to a working version I've simplified removing the _GET.

    Its still important that I have 3 forms on a page. But why can't I get a "name" property in the "form" tag and access it with _POST ($_POST['form_name'])?

    I feel dum. Why won't this work?

    All the inputs are the same, but its important which form you select, cuz I'm using a form as a tool to alter the page layout. Otherwise I could just add another input field to direct the various forms. Instead I use several pull-downs in the exact location where the change is to take effect. Its less abstract.
    -------------------------------------------------------
    Lenono W500/Archlinux
    Local: IBM x225/CentOS 6.5
    Remote: Hostnine.com

  5. #5
    SitePoint Zealot
    Join Date
    Oct 2009
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So this is me..."How have I used the name property in a form in the past? HMM...Well I've used it in JavaScript...Uhhh, this time its PHP...Why should it matter? Why is _POST not getting the name of the form... Hmm.... What about PHP.net...Nope...What about W3 School Tutorials? Nope...Lets look in the HTML 4.0 SpecificationNope... GeeeWiz, This is such a stupid question its not even in the specification. I feel Stupid."

    And where did I find it.... in another forum. Its get'n so a person can only find answers in a forum.
    -------------------------------------------------------
    Lenono W500/Archlinux
    Local: IBM x225/CentOS 6.5
    Remote: Hostnine.com


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
  •