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




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: … uctures.if
accessing data from a form using get or post: … 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 radio button 1 is selected
echo nl2br($output);  


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


You need to read up on and

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.