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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.