Jump to content

[SOLVED] Can't pick up PHP variables from Client Side drop down menu (?)


webmaster1

Recommended Posts

Hi All,

 

I'm calling on two dropdowns and writing their values back to a database:

<?php
//DROP DOWNS
$callresult1 = $_POST['optone'];
$callresult2 = $_POST['opttwo'];
?>

 

For some reason the variables come back as blank. I'm using the following client side script:

 

HEAD:

<script type="text/javascript">

function setOptions(chosen) {
var selbox = document.myform.opttwo;

selbox.options.length = 0;
if (chosen == " ") {
  selbox.options[selbox.options.length] = new Option('Secondary Result',' '); 
}

if (chosen == "1") {
  selbox.options[selbox.options.length] = new
Option('No Answer','oneone');
  selbox.options[selbox.options.length] = new
Option('Engaged Tone','onetwo');
}

if (chosen == "2") {
  selbox.options[selbox.options.length] = new
Option('No Decision Maker Available','twoone');
  selbox.options[selbox.options.length] = new
Option('Follow Up: Sending Email','twotwo');
  selbox.options[selbox.options.length] = new
Option('Follow Up: Decision Later','twothree');
}


if (chosen == "3") {
  selbox.options[selbox.options.length] = new
Option('Obsolete Number','threeone');
  selbox.options[selbox.options.length] = new
Option('Not Correct Contact','threetwo');
  selbox.options[selbox.options.length] = new
Option('Outdated Prefix','threethree');
}


if (chosen == "4") {
  PRIVATE
}

if (chosen == "5") {
  selbox.options[selbox.options.length] = new
Option('Overheads Too Expensive','fiveone');
  selbox.options[selbox.options.length] = new
Option('Already Taken Course','fivetwo');
  selbox.options[selbox.options.length] = new
Option('Not Applicable to Vocation','fivethree');
  selbox.options[selbox.options.length] = new
Option('Weak Belief in Market Viability','fivefour');
  selbox.options[selbox.options.length] = new
Option('Not Computer Literate','fivefive');
selbox.options[selbox.options.length] = new
Option('Out of Business','fivesix');
}

if (chosen == "6") {
  selbox.options[selbox.options.length] = new
Option('Reviewing Record','sixone');
  selbox.options[selbox.options.length] = new
Option('Editing Record','sixtwo');
}

}

</script>

<script language="javascript">


function enableField()
{

         if (document.myform.optone.value=="2")
         {
            document.myform.date.disabled=false;
            document.myform.month.disabled=false;
            document.myform.year.disabled=false;
            document.myform.hour.disabled=false;
            document.myform.minute.disabled=false;


         }
         else 
         {
            document.myform.date.disabled=true;
            document.myform.month.disabled=true;
            document.myform.year.disabled=true;
            document.myform.hour.disabled=true;
            document.myform.minute.disabled=true;
         }
         
}

</script>

 

BODY:

<p align="center">

<select style="width: 150px;" name="optone" id="optone" size="1" onchange="setOptions(document.myform.optone.options[document.myform.optone.selectedIndex].value); enableField();">
<option value=" " selected="selected"> Primary Result </option>
<option value="1">Non-Connect</option>
<option value="2">Schedule Call-Back</option>
<option value="3">Wrong Number</option>
<option value="4">Course Sale</option>
<option value="5">Refusal</option>
<option value="6">No Call Placed</option>
</select>

<select style="width: 250px;" name="opttwo" id="opttwo" size="1">
<option value=" " selected="selected" > Secondary Result </option>
</select>


<input style="width: 35px;" name="date" id="date" type="text" disabled="true" >/
<input style="width: 35px;" name="month" id="month" type="text" disabled="true" >/
<input style="width: 45px;" name="year" id="year" type="text" disabled="true" >

<input style="width: 35px;" name="hour" id="hour" type="text" disabled="true" >:
<input style="width: 35px;" name="minute" id="minute" type="text" disabled="true" >




</p>

Oh jaysus. It works fine now.

 

My default dropdown options had a blank value so when I used them to test whether the variables were writing back or not they simply posted a blank which is exactly what was supposed to happen.

 

Thanks for the explanation in any case Axeia.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.