|
Posted by IchBin on 11/21/06 01:53
I am trying to programmatically set a radio button in a table of radio
buttons. I have two problems with the code below:
1 - I can not prepare the <Form> statement to be printed by php.
(syntax of the hyphens, quotes) my fault!
2 - If I delete the <Form> and </Form> statements I can build the table
of radio buttons correctly, HTML wise. The fifth radio button has
'checked=True'. The problem is even though I set radio button 5 to be
checked only the last radio button is checked when it is displayed on
the screen. But viewing the page code says it should be the fifth radio
button.
Anybody have some ideas, I'm lost.
<?php
/**
Http://localhost/quotes/scrap.php?XDEBUG_SESSION_START=tswebeditor
*/
if(isset($_POST['abbr_letter']) ) {
$selectedNum = $_POST['abbr_letter'];
}
else {
$selectedNum = 1;
}
$value = 0;
$checked = 'false';
$selectedNum = 5;
$ColumBrake = 13;
print '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
print '<html xmlns="http://www.w3.org/1999/xhtml">';
print '<HTML>';
print '<HEAD>';
print '<title>Testiing radio Buttons</title>';
print '<link href="quotes.css" rel="stylesheet" type="text/css">';
print '<SCRIPT language=JavaScript src="quotesCss.js"
type="text/javascript"></SCRIPT>';
// print '<b><FORM NAME="author_abbrv" method="POST" action="'.<?php
echo $_SERVER['PHP_SELF'];?>.'"></b>';
print '</HEAD>';
print '<table><tbody><tr>';
foreach (range('A', 'Z') as $letter)
{
if( $value == $ColumBrake) {
print '</tr><tr>';
}
if( $value == $selectedNum) {
$checked = 'true';
print '<td><input type="radio" name="abbr_letter" value="'.
$value .'" checked="'. $checked .
'" onclick="submit()" />'.$letter.'</td>';
} else {
$checked = 'false';
print '<td><input type="radio" name="abbr_letter" value="'.
$value .'" checked="'. $checked .
'" onclick="submit()" />'.$letter.'</td>';
}
$value = $value +1;
}
print '</tr></tbody></table>';
// print '</FORM>';
print '</HTML>';
?>
--
Thanks in Advance... http://ichbin.9999mb.com
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
______________________________________________________________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
Navigation:
[Reply to this message]
|