Jump to content

[SOLVED] php and selections and radio


TheFilmGod

Recommended Posts

how do I use php to grab the selected option from a selection form.

 

<select name=\"notes\">
		<option selected=\"selected\">Microsoft Word Document
		<option>Rich Text Format
		<option>Simple Text Format
		<option>HTML
		<option>Other/Special File
	</select>

 

Code was in a php echo statement. Thus all double quotes were escaped.

 

The NAME = "notes"

 

What do I need to call within php to get the selected option?

 

Last thing radio group. How do I get the selected option. This is what I got:

 

<div id="radioleft"><input name="action[0]" type="radio" value="new" /> New Document</div>
<div id="radioright"><input name="action[1]" type="radio" value="update" /> Update a Present Document</div>

 

To get it with php:

 

// If new document selected..
if ( isset($action[0]) {

$form = "new";

}

// If update document selected..
if ( isset($action[1]) {

$form = "update";

}

 

I want $form to give me New or update, depending on selection.

 

 

Am I on a good start with the php script? I think I got the radio selections correct, but what about the select?

Link to comment
https://forums.phpfreaks.com/topic/67528-solved-php-and-selections-and-radio/
Share on other sites

I got the stuff to work. I was right along - for once!

 

Now I have a BIGGER problem:

 

<div id="radioleft"><input name="action[0]" type="radio" value="new" /> New Document</div>
<div id="radioright"><input name="action[1]" type="radio" value="update" /> Update a Present Document</div>

 

Since the names are different, the browser allows the user to select both of them! That is a no no! How can I make it so this doesn't happen, but I can call them in my php. - I simply want to do this:

 

// Set variables to check submission

$action[0] = $_POST['action'][0];

$action[1] = $_POST['action'][1];

 

how do I do this!!? help!! I'm a noob.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.