> Date: Thu, 27 May 2010 12:23:46 -0400 > To: ajwei@xxxxxxxxxxxxx; php-general@xxxxxxxxxxxxx > From: tedd.sperling@xxxxxxxxx > Subject: RE: Select Values Didn't Get Passed in From Two Different Forms > > At 3:50 PM -0400 5/26/10, Alice Wei wrote: > > > > My bad, I cannot imagine I sent that stuff. To answer your > >question, here it is, > > > > <form action="" method="post"> > > <p>Select the type of your starting point of interest:<br/> > > <input type="text" name="start" size="20" > >maxlength="50"/> > > > > <input type="submit" value="submit" name="submit"></p> > > </form> > > > > > >This is what is working now if I do it this way, but again, then I > >got to make sure everything is "typed up properly" before the form > >is submitted. Does this answer your questions by any chance? > > > > > >Alice > > > > Alice: > > Okay, not bad -- here's my addition: > > http://www.webbytedd.com/cccc/alice/ > > Please review the code. I removed the maxlength because that's > something you should do server-side anyway. Never trust anything > coming from the client-side. > > Also note that closing the tags, such as <br/> is optional -- IF -- > you're not planning on using XML. Otherwise they will generate a W3C > short-tags warning. However, that's not a fatal error. > > Also note the Submit button statement has three attributes. Type > states the type of input statement, value is what the button displays > to the user (i.e., Submit") and name is the name of the variable that > you can access via a POST/GET. > > Also note how the form collects the "start" value from a POST and > then repopulates the form after it has the data. This important to > understand. Clicking the "Submit" button sends the form's data to the > server which then sends it back to the browser via a refreshed form. > > Also note the ternary operator I used, namely: > > $start = isset($_POST['start']) ? $_POST['start'] : null; > > The first time the page is viewed, POST is sampled for content. If > there is no content, then checking for content will generate an error > unless we first check to see if it has content, hence the isset(). If > it doesn't have content, then the statement assigns NULL to $start. > If it does have content, then it will assign that value to $start, > understand? > > Now, what's next? What other data do you want to collect? You > mentioned a select control that derived its data from a database. But > before we go to that, show me a "select" control working in a form > with embedded values -- in other words, just a simple select control. > Please add it to the form we have. > > Cheers, > > > tedd > 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 > -- > ------- > 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