Here's my problem: I have two simple radio button options "Radians" and "Degrees" to pass to a Processor Page to dynamically populate cells in a Trig calculation table. So, I got the trig calculations working (give or take to rounding I need to apply ). <b>What I can't figure out is how to make the data in the first column of the table show degrees in increments of 15 when I click the "degree" button or to show "Radians" in the same increments when I click "Radians".</b> Note: the Radian numbers are really a set of image files numbered 0.gif, 15.gif, etc. I actually have that working okay. I just can't figure out how to change the column data based on what radio option is chosen. I have correctly coded the column header correctly to show either Radians or Degrees. Be advised I am using a "for" loop. I assumed an IF/Else statement would work, but it's not.
Here is condensed code from form page:
Here is code from PhP "Processor Page. Variables to note: $trigstuff is the variable containing the $_POST data from the form page.
$counter is the counter used in the "for" loop.
There are other variables I used for the calculations for the other columns, but those don't apply to the first column.
:
Thanks in advance for any and all assistance.
W!
Here is condensed code from form page:
Code:
<body>
<p id="header"> Display Trig Functions</p>
<form id="trigForm" action="trigfunct.php" method="post">
<p>
<label>Radian </label>
<input type="radio" name="calculation" value="Radian"/></p>
<p><label>Degrees</label>
<input type="radio" name="calculation" value="Degrees"/></p>
<p><input type="submit" value="Calculate" /></p>
</form>
</body>
$counter is the counter used in the "for" loop.
There are other variables I used for the calculations for the other columns, but those don't apply to the first column.
:
Code:
<?php
$trigStuff = $_POST['calculation'];
echo '<html>
<head>
<title>Trigonometry Function Page</title>
<link href="mainstyle.css" rel="stylesheet" type="text/css" />
</head>';
echo '<body>';
echo '<h2>Table of Sines, Cosines, and Tangents</h2>';
echo '<table>';
echo '<tr><th>';
echo $trigStuff;
echo '</th><th>sin(x)</th><th>cos(x)</th><th>tan(x)</th></tr>';
for ($counter = 0; $counter <= 360; $counter += 15) {
echo '<tr><td>';
if ($trigStuff == "Radians") {
echo '<img src="img'. $counter.'.gif" />';//These are all image files named in increments of 15. They work.
}
else {
echo $counter; // see the "For" loop. These will write data in increments of 15. It works
}
echo '</td><td>';
$convert = deg2rad($counter);
echo sin($convert); //sin function
echo '</td><td>';
echo cos($convert); // cos function
echo '</td><td>';
echo tan($convert); // tan function
echo '</td></tr>';
}
echo '</table>';
echo '</body>';
echo '</html>';
?>
Thanks in advance for any and all assistance.
W!