RE: [PHP] Select Values Didn't Get Passed in From Two Different Forms
| From: | Ashley Sheridan | Date: | Fri, 28 May 2010 19:14:06 +0000 |
| Subject: | RE: [PHP] Select Values Didn't Get Passed in From Two Different Forms | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-305615@lists.php.net to get a copy of this message | ||
On Fri, 2010-05-28 at 15:12 -0400, Alice Wei wrote:
> Subject: RE: [PHP] Select Values Didn't Get Passed in From Two
> Different Forms
> From: ash@ashleysheridan.co.uk
> To: ajwei@alumni.iu.edu
> CC: tedd.sperling@gmail.com; php-general@lists.php.net
> Date: Fri, 28 May 2010 20:05:29 +0100
>
> On Fri, 2010-05-28 at 15:00 -0400, Alice Wei wrote:
>
>
> Date: Fri, 28 May 2010 12:34:55 -0400
> > To: ajwei@alumni.iu.edu; php-general@lists.php.net
> > From: tedd.sperling@gmail.com
> > Subject: RE: [PHP] Select Values Didn't Get Passed in From Two Different
> > Forms
> >
> > At 9:19 PM -0400 5/27/10, Alice Wei wrote:
> > >
> > >I am not sure how to add to the page you have set up, but here is
> > >the code with ther portion you have set up:
> > >
> > >
> > ><?php
> > > $start = isset($_POST['start']) ? $_POST['start'] :
> > > null;
> > >?>
> > > <form action="" method="post">
> > > <p>
> > > Select the type of your starting point of interest:<br>
> > > <input type="text" name="start"
> > > value="<?php
> > >echo($start);?>" size="20" ><br />
> > > Which Semster is this: <select name="semester">
> > > <option
> > > value="Fall">Fall</option>
> > > <option
> > > value="Spring">Spring</option>
> > > <option
> > > value="Summer">Summer</option>
> > > </select><br/>
> > > <input type="submit" name="submit"
> > > value="Submit" >
> > > </p>
> > > </form>
> > >
> > > Note, what I provided here does not include anything on the ajax.
> > >
> > >Hope this answers your question.
> >
> > Alice :
> >
> > I didn't have a question, but here's my revision of your code:
> >
> > http://www.webbytedd.com/cccc/alice1/
> >
> > Please review the code and see how: 1) I captured the select value;
> > 2) and how I used that value to focus the selected option.
> >
> > You say:
> >
> > > Note, what I provided here does not include anything on the ajax.
> >
> > I've never put anything "on the ajax" -- that doesn't make
> > sense.
> >
> > Ajax is simply a way to communicate from the browser to the server
> > and back again without requiring a browser refresh. As the user
> > triggers a client-side event (i.e., click, select, enter text, move a
> > mouse, whatever), a javascript routine then sends data to the server
> > to activate a server-side script, which may, or may not, return data.
> >
> > For example -- with javascript turned ON please review:
> >
> > http://www.webbytedd.com/a/ajax-site/
> >
> > This is simply a one page template that uses an ajax routine to
> > retrieve data from the server to populate the page based upon what
> > the user triggers (i.e., the visitor clicks a navigational link).
> >
> > If you will review the HTML source code, you will find a very basic
> > HTML template that will remain static for all three "apparent" pages.
> > If you use the FireFox browser you can review the generated HTML.
> >
> > Now where did the generated HTML come from, you might ask? It came
> > from the server after a request was made from the client to the
> > server and the server responded with the correct data -- all without
> > requiring a browser refresh. That's an example of how ajax works.
> >
> > Keep in mind that using "best practices" requires you to *first*
> > design forms to collect data WITHOUT requiring javascript and then
> > you can enhance the form to provide additional functionality to those
> > who have javascript turned on. Also keep in mind that you may not
> > need ajax to alter the form. You only need ajax if there is data on
> > the server that needs to be retrieved.
> >
> > Now, please turn javascript OFF in your browser and review my page again:
> >
> > http://www.webbytedd.com/a/ajax-site/
> >
> > That's an example of NOT following "best practices". The visitor is
> >
> > provided nothing if they have javascript turned OFF.
> >
> > Now considering such, what additional functionality do you want your
> > form to do that can't be done already?
> >
> > Cheers,
> >
> > tedd
> >
> > --
>
> Tedd,
>
> What I am trying to find out is, when I have my form with a dependent select menu,
> how can I pass the value of the select menu to another page? I have mentioned in the initial email
> that if I just allow users to type stuff, it passes the form back to itself and works. However, what
> I want
> to do is to allow users click one radio button/checkbox, and use that value to
> determine which "select menu" to bring up. However, the information I am only interested
> in storing, is the value of the select menu and not the radio button/checkbox.
>
> Am I making sense here?
>
> Alice
> > -------
> > http://sperling.com ×¼
> > ›Ã&Îé`¨À?¯http://ancientstones.com
> > http://earthstones.com
>
> _________________________________________________________________
> The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with Hotmail.
>
> http://www.windowslive.com/campaign/thenewbusy?tile=multicalendar&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_5
>
>
> You could do this a couple of ways:
>
> 1) Have all the possible form elements you need and show the one the
> user needs with Javascript
> 2) Use ajax to grab the select list you need based on the users
> selection and add it in to the current form.
>
> It doesn't matter if you submit more form elements than you need, just
> don't use them when the form is submitted to the php script.
>
> In my example, I think that is what I used. I used the javascript to
> toggle the different results based on which selection the user made,
> which the request is made to the server to find out what needs to be
> pulled. However, the problem with this is, it looks like when the user
> selects something from the drop down list that is created from Ajax,
> that value cannot be passed back to another PHP script to insert into
> the database. I even tried looking at the source code when there is a
> "dependent select menu" on the screen, it looks like I don't see any
> html code that is supposed to produce by the php on what elements are
> of the dependent select menu. Yet, everything is there on the screen.
>
> Maybe that is why I cannot pass the information on in the "hidden"
> value, but what have I missed here? Ajax? PHP? I am getting confused.
>
> Alice
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
>
>
> ______________________________________________________________________
> Hotmail has tools for the New Busy. Search, chat and e-mail from your
> inbox. Learn more.
No, the problem you had was two forms on the same page and you wanted
values from both!
What does your ajax javascript look like?
Thanks,
Ash
http://www.ashleysheridan.co.uk