Click to See Complete Forum and Search --> : parse a listbox with php


JeffyB
January 24th, 2008, 04:15 PM
Sorry up front to ask such a noob question and yes, I've Googled...came close but no Monica Lewin...I mean cigar.

What I need to do is simple. I need to take all the contents of a listbox and print them out to a file. Selected entries in the listbox don't matter. If one item is selected or none (this isn't a multiple listbox)...I need everything to go into a file. The reason I don't care about what's selected is because this listbox actually stores multiple entries that the user adds via a textbox. So, the user is creating the entries in the listbox (which is being handled by javascript).

I've figured out how to write to a file with PHP.

So here's some code. One the page the user sees:

<form name="testing123" action="write2file.php" method="post">

<select name="myList" size="10">

<option>one</option>
<option>two</option>
<option>three</option>

</select>

</form>

When the user submits this form, I want:

one
two
three

written out to a file, each and every <option> on its own line in the file.

Please be advised that this is my first jump into PHP, so you can't make your responses "too simple"....I'm simple enough! :)

Thanks in advance.
Jeff

PeejAvery
January 24th, 2008, 10:02 PM
When submitting a form the <select> tag will only pass the currently selected value to the PHP page. You will have to pass those values through an <input> tag with its type property set to hidden.