Hi, just wonderign if it was possible to set up Radio button with php like this:
<form method="post" action="$PHP_SELF?func=sign">
MSG Icon:
<input type="radio" value="<? $img=1 ?>" name="funimage" checked> <img src=http://www.htmlforums.com/archive/index.php/"smilie5.jpg">
<input type="radio" value="<? $img=2 ?>" name="funimage" ><img src=http://www.htmlforums.com/archive/index.php/"smilie4.jpg">
<input type="radio" value="<? $img=3 ?>" name="funimage" > <img src=http://www.htmlforums.com/archive/index.php/"smilie3.jpg">
<input type="radio" value="<? $img=4 ?>" name="funimage" > <img src=http://www.htmlforums.com/archive/index.php/"smilie2.jpg">
<input type="radio" value="<? $img=5 ?>" name="funimage" > <img src=http://www.htmlforums.com/archive/index.php/"smilie1.jpg">
<input type="submit" value="Submit" />
</form>
When I submit(refresh) the page, will $img have the value of the radio button selected?$img would equal 5.
PHP is a pre-proccessed language and runs before the HTML is sent to the browser. It is great for writing different html pages (and many other tricks also) on the fly.
You can send the data back to the same PHP page i.e. -
<form method="post" action="thispage.php?func=sign">
MSG Icon:
<input type="radio" value="5" name="funimage" checked /> <img src=http://www.htmlforums.com/archive/index.php/"smilie5.jpg" />
<br />
<input type="radio" value="4" name="funimage" >
<img src=http://www.htmlforums.com/archive/index.php/"smilie4.jpg" />
<br />
<input type="radio" value="3" name="funimage" />
<img src=http://www.htmlforums.com/archive/index.php/"smilie3.jpg" />
<br />
<input type="radio" value="2" name="funimage" />
<img src=http://www.htmlforums.com/archive/index.php/"smilie2.jpg" />
<br />
<input type="radio" value="1" name="funimage" />
<img src=http://www.htmlforums.com/archive/index.php/"smilie1.jpg" />
<br />
<input type="submit" name="btnSubmit" value="Submit" />
<br />
</form>
<?
if ($_POST['btnSubmit']){
?>
<br />
Your selection was button number <? print $_POST['funimage']; ?>.
<?
}
?>Originally posted by PlyWooD
Hi, just wonderign if it was possible to set up Radio button with php like this:
<form method="post" action="$PHP_SELF?func=sign">
MSG Icon:
<input type="radio" value="<? $img=1 ?>" name="funimage" checked> <img src=http://www.htmlforums.com/archive/index.php/"smilie5.jpg">
<input type="radio" value="<? $img=2 ?>" name="funimage" ><img src=http://www.htmlforums.com/archive/index.php/"smilie4.jpg">
<input type="radio" value="<? $img=3 ?>" name="funimage" > <img src=http://www.htmlforums.com/archive/index.php/"smilie3.jpg">
<input type="radio" value="<? $img=4 ?>" name="funimage" > <img src=http://www.htmlforums.com/archive/index.php/"smilie2.jpg">
<input type="radio" value="<? $img=5 ?>" name="funimage" > <img src=http://www.htmlforums.com/archive/index.php/"smilie1.jpg">
<input type="submit" value="Submit" />
</form>
When I submit(refresh) the page, will $img have the value of the radio button selected?
no tha twill not work. you do not set the value of the radio button that way. you have to echo the $img variable, in that code all you do it set the variable to = a number.
<form method="post" action="$PHP_SELF?func=sign">
MSG Icon:
<input type="radio" value="<? $img=1 ?>" name="funimage" checked> <img src=http://www.htmlforums.com/archive/index.php/"smilie5.jpg">
<input type="radio" value="<? $img=2 ?>" name="funimage" ><img src=http://www.htmlforums.com/archive/index.php/"smilie4.jpg">
<input type="radio" value="<? $img=3 ?>" name="funimage" > <img src=http://www.htmlforums.com/archive/index.php/"smilie3.jpg">
<input type="radio" value="<? $img=4 ?>" name="funimage" > <img src=http://www.htmlforums.com/archive/index.php/"smilie2.jpg">
<input type="radio" value="<? $img=5 ?>" name="funimage" > <img src=http://www.htmlforums.com/archive/index.php/"smilie1.jpg">
<input type="submit" value="Submit" />
</form>
When I submit(refresh) the page, will $img have the value of the radio button selected?$img would equal 5.
PHP is a pre-proccessed language and runs before the HTML is sent to the browser. It is great for writing different html pages (and many other tricks also) on the fly.
You can send the data back to the same PHP page i.e. -
<form method="post" action="thispage.php?func=sign">
MSG Icon:
<input type="radio" value="5" name="funimage" checked /> <img src=http://www.htmlforums.com/archive/index.php/"smilie5.jpg" />
<br />
<input type="radio" value="4" name="funimage" >
<img src=http://www.htmlforums.com/archive/index.php/"smilie4.jpg" />
<br />
<input type="radio" value="3" name="funimage" />
<img src=http://www.htmlforums.com/archive/index.php/"smilie3.jpg" />
<br />
<input type="radio" value="2" name="funimage" />
<img src=http://www.htmlforums.com/archive/index.php/"smilie2.jpg" />
<br />
<input type="radio" value="1" name="funimage" />
<img src=http://www.htmlforums.com/archive/index.php/"smilie1.jpg" />
<br />
<input type="submit" name="btnSubmit" value="Submit" />
<br />
</form>
<?
if ($_POST['btnSubmit']){
?>
<br />
Your selection was button number <? print $_POST['funimage']; ?>.
<?
}
?>Originally posted by PlyWooD
Hi, just wonderign if it was possible to set up Radio button with php like this:
<form method="post" action="$PHP_SELF?func=sign">
MSG Icon:
<input type="radio" value="<? $img=1 ?>" name="funimage" checked> <img src=http://www.htmlforums.com/archive/index.php/"smilie5.jpg">
<input type="radio" value="<? $img=2 ?>" name="funimage" ><img src=http://www.htmlforums.com/archive/index.php/"smilie4.jpg">
<input type="radio" value="<? $img=3 ?>" name="funimage" > <img src=http://www.htmlforums.com/archive/index.php/"smilie3.jpg">
<input type="radio" value="<? $img=4 ?>" name="funimage" > <img src=http://www.htmlforums.com/archive/index.php/"smilie2.jpg">
<input type="radio" value="<? $img=5 ?>" name="funimage" > <img src=http://www.htmlforums.com/archive/index.php/"smilie1.jpg">
<input type="submit" value="Submit" />
</form>
When I submit(refresh) the page, will $img have the value of the radio button selected?
no tha twill not work. you do not set the value of the radio button that way. you have to echo the $img variable, in that code all you do it set the variable to = a number.