Form Options via Radio (buttons)

Creating a form that chooses two variables depending on the selection of one of two radio buttons.

How would I do this? It is only a simple script and I would like the form which is only a text field input which is to be turned into a string and the two radio options which decide wheter the string is processed by highlight_string or show_source for example.

Thanks all!!

Gav.

HuH???

Maybe it’s me but I am not sure what you are asking…

Either way… What have you tried to resolve it?
We are here to HELP not to write your scripts for you.

I think Paul put it best with HUH?!! Please try to clearify what you are trying to accomplish and let us know what you have tried.

i think what you’re trying to ask is how to use basic statements, such as an if clause, and access variables from a submitted form, using either a method of get or post. if that’s the case, you need to read up a bit on your php:

if statements: http://us3.php.net/manual/en/language.c … uctures.if
accessing data from a form using get or post: http://us3.php.net/manual/en/language.v … ternal.php

Sort of the right lines.

I mean like you have a form, and on it you have a text input, two radio buttons and a submit button.

When submit is clicked, the PHP script should process the value of the text box depending on which radio button is selected.

I.e. sort of like this I guess: -


$source = file_get_contents($input);  
$output = htmlspecialchars($source); 

// what should I set this statement as? 
  if  

//if radio button 1 is selected
echo nl2br($output);  

  else 

//if radio button 2 is selected
echo "<pre>n $output n</pre>" 
}

You need to read up on http://us3.php.net/else and http://us3.php.net/manual/en/language.control-structures.php#control-structures.if

Understanding IF structures is a basic of ALL programming. I think any explanation here would be a waste. We are here to help, not write your scripts but you must help yourself and learn the basics. Those links above should get you started.

Sponsor our Newsletter | Privacy Policy | Terms of Service