Tuesday, February 22, 2011

A Small Problem

I have one PHP script where there are two options for the users to
choose.

Option 1 is to Select the type of Graph and Option 2 is to choose from
[Day, Week, Month or Year] now it looks like this.

//For Option 1

if (!isset($_POST['mydropdown'])){
$value = 4;}else{
$value = $_POST['mydropdown'];} // take a value from dropdown and
change the chart according to that.

if ($value == 1){
$chart_type = "ColumnChart";} // Colume Chart
else if ($value == 2) {
$chart_type = "BarChart";} // Bar Chart
else if ($value == 3) {
$chart_type = "LineChart";} // Line Chart
else if ($value == 4) {
$chart_type = "PieChart";} // Pie chart

//Now For Option 2

If (!isset($_POST['days'])) // from checklogin.php
{
$Date = subtractDaysFromToday(30);
}else{
$value = $_POST['days'];
$Date = subtractDaysFromToday($value);
}

HTML for both options are as follow.

Option 1

<form name="myform" action="./view_activity.php" method="POST">

Choose your chart Type:
<select name="mydropdown">
<option value="">Select Your Chart</option>
<option value="1">Column Chart</option>
<option value="2">Bar Chart</option>
<option value="3">Line Chart</option>
<option value="4">Pie Chart</option>
</select>
<br><input type="submit" value="Submit"><br>

</form>

Option 2

<form name="myform" action="./view_activity.php" method="POST">
<input type="hidden" name="days" value="0" />
<input type="submit" value="Day">
</form>
</td><td>
<form name="myform" action="./view_activity.php" method="POST">
<input type="hidden" name="days" value="7" />
<input type="submit" value="Week">
</form>
</td><td>
<form name="myform" action="./view_activity.php" method="POST">
<input type="hidden" name="days" value="30" />
<input type="submit" value="Month">
</form>
</td><td>
<form name="myform" action="./view_activity.php" method="POST">
<input type="hidden" name="days" value="365" />
<input type="submit" value="Year">
</form>

Now problem is if user choose any option from [Day, Week, Month or
Year] Option 1 sets to default, it means PieChart and if User choose
any graph e.g Bar chart and want to see Month view it again shows
PieChart. How to handle this problem so user can have choose both
options.

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: