I am an asp.net developer trying to get more familiar with php. How do you auto post back in php. I have a drop down filled with users when a user is selected I want to populate some text boxes. This is really easy to do in asp by just setting the drop down autopostback property to true. Any help would be appreciated.

    Sorry, I am not sure I understood. You have a select box, and a text box. And when you select an option from the select box, it populates the text box?

    I am not sure how an autopostback set to true would do anything, based on what I understood from you.

      maybe i didnt do a good job of explaining. When I select something from the drop down list I want to fill the text boxes with the info that corresponds but I do not know how to accomplish this. In asp.net there is an event that would be called on post back and that is where you would populate your fields. How do I accomplish this in php?

        Can you be a little more specific? Could you show me a code snippet?

          Well, you could look at those big JavaScript libraries that ASP.NET links into the pages.

            As I have always understood it that doing callbacks (auto-postbacks) with PHP requires AJAX in sorts, or just javascript.

            The reason for this is that PHP is server-side where as Javascript is client side. This means that a user will call a .php page and the server will execute the code on the server and then returns the results to the browser. Where as Javascript executes the code on a 'by call' basis. So if you have a button on the page and you use the html

            <button onClick="javascriptButtonFunction()" > when the user clicks the button this would send a request for the code that is within the "javascriptButtonFunction()" function and it does what ever without a page refresh (unless there is one with the code).

            You can harness the two so that javascript calls a php script and the php executes and returns back to the client without a refresh, or in other words a callback.

            To learn more do some google searches for AJAX. It can be confusing, but it is very powerful!!

            I hope this clears things up.

              Write a Reply...