Subject: RE: [PHP] Select Values Didn't Get Passed in From Two Different Forms
Date: Fri, 28 May 2010 20:14:06 +0100


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 




    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:;
> From:
> 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:
> 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:
> 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:
> 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
> -- 


  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  

Am I making sense here? 

> -------
The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with 


    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.









    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!

  Well, you are right. The way I would like to have it is to have a main form 
with some text fields for users to type in stuff, which are not relevant to the 
"drop down menus", and another two where users could select radio buttons and 
each time a radio button is clicked, then the drop down menu would dynamically 
be changed. 

  I figured that if I know how to do one properly, then I am sure I could 
figure out the other. 

                                <div id="start_menu"><form 
action="test_getrss.php" name="form1" method="post">

type="radio" value="Apartment" name="start"

onclick="check(document.form1.start)"/> Apartment </span>

type="radio" value="Drugstore" name="start"

onclick="check(document.form1.start)"/> Drug Store </span></p>


                           <form action="process.php" 

                        <input type="hidden" name="form1" 
value="<?php echo $start?>"/>

type="submit" value="Submit" name="submit"/>

                        <input type="reset" value="Reset" 


What does your ajax javascript look like?

Here it is: 

function check(field)
  var str ="";
  for (i=0;i<field.length;i++)
  if (field[i].checked==true) str = field[i].value + " ";  
  var url = "test_getrss.php?q=" + str;"GET",url,true);

function start_menu() {

if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  if (xmlhttp.readyState==4 && xmlhttp.status==200){
  if(xmlhttp.responseText == " ") alert("Unable to process request");

Does this help illustrate what I want to do here?




The New Busy is not the old busy. Search, chat and e-mail from your inbox.

Reply via email to