Results 1 to 4 of 4

Thread: PHP getting a form element

  1. #1
    Join Date
    Jul 2008
    Posts
    65
    Thanks
    42
    Thanked 0 Times in 0 Posts

    Default PHP getting a form element

    I have a form, and I need to select some stuff out of a database like this
    Code:
    SELECT name FROM misc_a WHERE parent=(form value inserted here)
    Then the value that is returned is going to go in a SELECT list so I don't want to reload the page. Is there anyway I can get the form value, without reloading the page, or using Ajax?
    Last edited by hosdank; 08-25-2008 at 05:51 PM. Reason: typo

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    You must use ajax, there is no other way to do it without the page reloading.
    Jeremy | jfein.net

  3. #3
    Join Date
    Aug 2007
    Location
    Ohio
    Posts
    79
    Thanks
    0
    Thanked 15 Times in 15 Posts

    Default

    Nile is correct.

    The form would be being displayed in a user's browser on his or her own machine. It has no access to the data on the server. In order to access server data, you need to send a new HTTP request either through ajax, or through a new page load.

    If the reason you're shying away from ajax or a new page load is speed, there's an alternative depending on the size of your database. Theoretically, you could select all the rows in the applicable database, and store the data in hidden elements within your page. When they submit the form, you'd prevent the default action, and loop through the hidden data taking only what you need. This would only be feasible with a very small database, but I thought I'd give you the option.

  4. #4
    Join Date
    Jul 2008
    Posts
    65
    Thanks
    42
    Thanked 0 Times in 0 Posts

    Default

    Thanks

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
  •