Shogikishi
05-09-2008, 12:27 AM
Hi,
Can someone be the expert I need and help me see why I can't get this value to pass in PHP?
I have a PHP page with three DIVs. On page load, only the first DIV (DIV#1) has controls. The first DIV (DIV#1) contains a button that, when clicked, generates a control and button in DIV#2. The intent is to have a user select a value from a list box in DIV#2 and then click an action button also in DIV#2. The resulting action should be for the value selected in the listbox of DIV#2 to be displayed in DIV#3. I am using AjaxCore/Prototype.js for AJAX like effects.
The listbox is displayed and appears ok, but I cannot get a value from the listbox (Select Tag). When I use Select Tag the button passes an empty variable.
When I swap out the Select Tag section for a simple Input Class=textfield, then it all works! Please see code snippet below.
How do I get this working with a listbox or something like it?
-Shogikishi
###DIV#1 button has onclick function to Workspace1(). This is where the controls are created as text and inserted into DIV#2 as innerHTML.
###The button in DIV#2 has onclick function to ChartType1(). When a InputClass of TextField is used, then it prints the value put in the textbox. When a Select Tag is used instead, it doesn't print the value.
###################
public function Workspace1()
{
$this->Workspace1Controls();
}
# populate workspace1
private function Workspace1Controls()
//onMouseOver="alertselected()"
{
$var = (!empty($_REQUEST['selectSY']))?$_REQUEST['selectSY']:'';
//$html .= '<form id="ChartType1Controls" name="ChartType1Controls" method="post" >';
$html .= '<label for="selectSY">School Year </label><br/>';
#############################
# Want it as a listbox
##############################
$html .= '<select name="selectSY" id="selectSY">
<option value="'.$var.'">2003 - 2004</option>
<option value="'.$var.'">2004 - 2005</option>
<option value="'.$var.'">2005 - 2006</option>
<option value="'.$var.'">2006 - 2007</option>
<option value="'.$var.'" selected="selected">2007 - 2008</option></select>';
###########################
# Try it as a text input field and it works!
############################
//$html .= '<input class="textfield" type="text" name="selectSY" id="selectSY" value="'.$var.'" />';
##################
$html .= '<input class="btnfield" type="button" id="chart1_btn" name="chart1_btn" value="Create Chart" onclick="'.$this->bindInline("ChartType1", "selectSY").'"/>';
$html .= '</form>';
//echo $this->htmlInner("controls",$html);
echo $this->htmlInner("controls",$html);
}
####################################
# START PULL CHART TYPE 1
#######################################
public function ChartType1()
{
//selectedItem = this.ChartType1Controls.selectSY.selectedIndex;
//selectedValue = this.ChartType1Controls.selectSY.options[selectedItem].value;
$var = (!empty($_REQUEST['selectSY']))?$_REQUEST['selectSY']:'';
if ($var=="")
{
echo "The variable container is empty";
}
$SY = $var;
echo $SY." is the value";
//echo include("../Chart1/Index.php");
//echo include_once("../Chart1/Index.php");
}
Can someone be the expert I need and help me see why I can't get this value to pass in PHP?
I have a PHP page with three DIVs. On page load, only the first DIV (DIV#1) has controls. The first DIV (DIV#1) contains a button that, when clicked, generates a control and button in DIV#2. The intent is to have a user select a value from a list box in DIV#2 and then click an action button also in DIV#2. The resulting action should be for the value selected in the listbox of DIV#2 to be displayed in DIV#3. I am using AjaxCore/Prototype.js for AJAX like effects.
The listbox is displayed and appears ok, but I cannot get a value from the listbox (Select Tag). When I use Select Tag the button passes an empty variable.
When I swap out the Select Tag section for a simple Input Class=textfield, then it all works! Please see code snippet below.
How do I get this working with a listbox or something like it?
-Shogikishi
###DIV#1 button has onclick function to Workspace1(). This is where the controls are created as text and inserted into DIV#2 as innerHTML.
###The button in DIV#2 has onclick function to ChartType1(). When a InputClass of TextField is used, then it prints the value put in the textbox. When a Select Tag is used instead, it doesn't print the value.
###################
public function Workspace1()
{
$this->Workspace1Controls();
}
# populate workspace1
private function Workspace1Controls()
//onMouseOver="alertselected()"
{
$var = (!empty($_REQUEST['selectSY']))?$_REQUEST['selectSY']:'';
//$html .= '<form id="ChartType1Controls" name="ChartType1Controls" method="post" >';
$html .= '<label for="selectSY">School Year </label><br/>';
#############################
# Want it as a listbox
##############################
$html .= '<select name="selectSY" id="selectSY">
<option value="'.$var.'">2003 - 2004</option>
<option value="'.$var.'">2004 - 2005</option>
<option value="'.$var.'">2005 - 2006</option>
<option value="'.$var.'">2006 - 2007</option>
<option value="'.$var.'" selected="selected">2007 - 2008</option></select>';
###########################
# Try it as a text input field and it works!
############################
//$html .= '<input class="textfield" type="text" name="selectSY" id="selectSY" value="'.$var.'" />';
##################
$html .= '<input class="btnfield" type="button" id="chart1_btn" name="chart1_btn" value="Create Chart" onclick="'.$this->bindInline("ChartType1", "selectSY").'"/>';
$html .= '</form>';
//echo $this->htmlInner("controls",$html);
echo $this->htmlInner("controls",$html);
}
####################################
# START PULL CHART TYPE 1
#######################################
public function ChartType1()
{
//selectedItem = this.ChartType1Controls.selectSY.selectedIndex;
//selectedValue = this.ChartType1Controls.selectSY.options[selectedItem].value;
$var = (!empty($_REQUEST['selectSY']))?$_REQUEST['selectSY']:'';
if ($var=="")
{
echo "The variable container is empty";
}
$SY = $var;
echo $SY." is the value";
//echo include("../Chart1/Index.php");
//echo include_once("../Chart1/Index.php");
}