• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 300
  • Last Modified:

Hiding a Text-field on certain events

Hi All,
So I have an admin section for a site where a user can enter a new phone model. Only certain models have cables so I only want the cable selection drop down (cab_select) to only appear if the user selects "Yes" from the previous question. (The previous drop-down asks "Does this phone has a cable?"). Therefore only on "YES" do I want the drop-down to appear and have its value entered to the DB. At the moment its inital value is sent to the DB regardless of whether or not the user changes the YES/NO drop-down. Any help would be appreciated greatly. Here's the code so far if it helps :)
Thanks,
D

<?php require_once('../Connections/GSM_mobile.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "add_model_frm")) {
  $insertSQL = sprintf("INSERT INTO model_table (mod_model_name, mod_type_id, mod_cable_id) VALUES (%s, %s, %s)",
                       GetSQLValueString($_POST['txt_name_model'], "text"),
                       GetSQLValueString($_POST['Brand'], "int"),
                       GetSQLValueString($_POST['cab_select'], "int"));

  mysql_select_db($database_GSM_mobile, $GSM_mobile);
  $Result1 = mysql_query($insertSQL, $GSM_mobile) or die(mysql_error());
}

mysql_select_db($database_GSM_mobile, $GSM_mobile);
$query_rsCatMod = "SELECT category_table.cat_category_id, category_table.cat_category_name, type_table.type_type_id, type_table.type_type_name, type_table.type_category_id FROM category_table, type_table WHERE category_table.cat_category_id = type_table.type_category_id";
$rsCatMod = mysql_query($query_rsCatMod, $GSM_mobile) or die(mysql_error());
$row_rsCatMod = mysql_fetch_assoc($rsCatMod);
$totalRows_rsCatMod = mysql_num_rows($rsCatMod);

mysql_select_db($database_GSM_mobile, $GSM_mobile);
$query_rsCables = "SELECT cable_table.cab_cable_id, cable_table.cab_cable_name FROM cable_table";
$rsCables = mysql_query($query_rsCables, $GSM_mobile) or die(mysql_error());
$row_rsCables = mysql_fetch_assoc($rsCables);
$totalRows_rsCables = mysql_num_rows($rsCables);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<form id="add_model_frm" name="add_model_frm" method="POST" action="<?php echo $editFormAction; ?>">
  <p>Welcome to The Add Phone Model Category:</p>
  <p>
    <label>Enter the new model name:
    <input name="txt_name_model" type="text" id="txt_name_model" />
    </label>
</p>
  <p>Please Select The Category:
    <select name="Category" id="Category" onchange="TCN_reload(this)">
      <option selected="selected">Category</option>
    </select>
  </p>
  <p>Please Select The Brand:
    <select name="Brand" id="Brand" onchange="TCN_reload(this)">
      <option selected="selected">Brand</option>
          </select>
    <script language="JavaScript" type="text/javascript">
TCN_contents=new Array();
TCN_tempArray=new Array();
TCN_counter=0;
function TCN_addContent(str){
      TCN_contents[TCN_counter]=str;
      TCN_counter++;
}
function TCN_split(){
      TCN_arrayValues = new Array();
      for(i=0;i<TCN_contents.length;i++){
            TCN_arrayValues[i]=TCN_contents[i].split(separator);
            TCN_tempArray[0]=TCN_arrayValues;
      }
}
function TCN_makeSelValueGroup(){
      TCN_selValueGroup=new Array();
      var args=TCN_makeSelValueGroup.arguments;
      for(i=0;i<args.length;i++){
            TCN_selValueGroup[i]=args[i];
            TCN_tempArray[i]=new Array();
      }
}
function TCN_makeComboGroup(){
      TCN_comboGroup=new Array();
      var args=TCN_makeComboGroup.arguments;
      for(i=0;i<args.length;i++) TCN_comboGroup[i]=findObj(args[i]);
}
function TCN_setDefault(){
      for (i=TCN_selValueGroup.length-1;i>=0;i--){
            if(TCN_selValueGroup[i]!=""){
                  for(j=0;j<TCN_contents.length;j++){
                        if(TCN_arrayValues[j][(i*2)+1]==TCN_selValueGroup[i]){
                              for(k=i;k>=0;k--){
                                    if(TCN_selValueGroup[k]=="") TCN_selValueGroup[k]=TCN_arrayValues[j][(k*2)+1];
                              }
                        }
                  }
            }
      }
}
function TCN_loadMenu(daIndex){
      var selectionMade=false;
      daArray=TCN_tempArray[daIndex];
      TCN_comboGroup[daIndex].options.length=0;
      for(i=0;i<daArray.length;i++){
            existe=false;
            for(j=0;j<TCN_comboGroup[daIndex].options.length;j++){
                  if(daArray[i][(daIndex*2)+1]==TCN_comboGroup[daIndex].options[j].value) existe=true;
            }
            if(existe==false){
                  lastValue=TCN_comboGroup[daIndex].options.length;
                  TCN_comboGroup[daIndex].options[TCN_comboGroup[daIndex].options.length]=new Option(daArray[i][daIndex*2],daArray[i][(daIndex*2)+1]);
                  if(TCN_selValueGroup[daIndex]==TCN_comboGroup[daIndex].options[lastValue].value){
                        TCN_comboGroup[daIndex].options[lastValue].selected=true;
                        selectionMade=true;
                  }
            }
      }
      if(selectionMade==false) TCN_comboGroup[daIndex].options[0].selected=true;
}      
function TCN_reload(from){
      if(!from){
            TCN_split();
            TCN_setDefault();
            TCN_loadMenu(0);
            TCN_reload(TCN_comboGroup[0]);
      }else{
            for(j=0; j<TCN_comboGroup.length; j++){
                  if(TCN_comboGroup[j]==from) index=j+1;
            }
            if(index<TCN_comboGroup.length){
                  TCN_tempArray[index].length=0;
                  for(i=0;i<TCN_comboGroup[index-1].options.length;i++){
                        if(TCN_comboGroup[index-1].options[i].selected==true){
                              for(j=0;j<TCN_tempArray[index-1].length;j++){
                                    if(TCN_comboGroup[index-1].options[i].value==TCN_tempArray[index-1][j][(index*2)-1]) TCN_tempArray[index][TCN_tempArray[index].length]=TCN_tempArray[index-1][j];
                              }
                        }
                  }
            TCN_loadMenu(index);
            TCN_reload(TCN_comboGroup[index]);
            }
      }
}
function findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
TCN_makeSelValueGroup("","");
TCN_makeComboGroup("Category","Brand");
 var separator="+#+";
<?php do{?>
TCN_addContent("<?php echo $row_rsCatMod['cat_category_name']; ?>+#+<?php echo $row_rsCatMod['cat_category_id']; ?>+#+<?php echo $row_rsCatMod['type_type_name']; ?>+#+<?php echo $row_rsCatMod['type_type_id']; ?>");
<?php } while ($row_rsCatMod = mysql_fetch_assoc($rsCatMod)); ?>
TCN_reload();

    </script>
  </p>
 
  <p>
    <label>Does this phone has a cable?
    <select name="cab_yes_no" id="cab_yes_no">
      <option>No</option>
      <option>Yes</option>
    </select>
    </label>
  </p>
  <p>
    <label>Select the Cable:
    <select name="cab_select" id="cab_select">
      <?php
do {  
?>
      <option value="<?php echo $row_rsCables['cab_cable_id']?>"><?php echo $row_rsCables['cab_cable_name']?></option>
      <?php
} while ($row_rsCables = mysql_fetch_assoc($rsCables));
  $rows = mysql_num_rows($rsCables);
  if($rows > 0) {
      mysql_data_seek($rsCables, 0);
        $row_rsCables = mysql_fetch_assoc($rsCables);
  }
?>
    </select>
    </label>
  </p>
  <input type="hidden" name="MM_insert" value="add_model_frm">
  <label>
  <input name="submit_btn" type="submit" id="submit_btn" value="Add Model Now" />
  </label>
</form>
</body>
</html>
<?php
mysql_free_result($rsCatMod);

mysql_free_result($rsCables);
?>
0
dereksheahan
Asked:
dereksheahan
  • 11
  • 11
1 Solution
 
Jason C. LevineNo oneCommented:
Hi Derek,

So long as this is an admin page and not visible to the general public, go ahead and place that field in a layer, then use and modify the Show-Hide Layers behavior to make it disappear and reappear as needed:

<?php require_once('../Connections/GSM_mobile.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "add_model_frm")) {
  $insertSQL = sprintf("INSERT INTO model_table (mod_model_name, mod_type_id, mod_cable_id) VALUES (%s, %s, %s)",
                       GetSQLValueString($_POST['txt_name_model'], "text"),
                       GetSQLValueString($_POST['Brand'], "int"),
                       GetSQLValueString($_POST['cab_select'], "int"));

  mysql_select_db($database_GSM_mobile, $GSM_mobile);
  $Result1 = mysql_query($insertSQL, $GSM_mobile) or die(mysql_error());
}

mysql_select_db($database_GSM_mobile, $GSM_mobile);
$query_rsCatMod = "SELECT category_table.cat_category_id, category_table.cat_category_name, type_table.type_type_id, type_table.type_type_name, type_table.type_category_id FROM category_table, type_table WHERE category_table.cat_category_id = type_table.type_category_id";
$rsCatMod = mysql_query($query_rsCatMod, $GSM_mobile) or die(mysql_error());
$row_rsCatMod = mysql_fetch_assoc($rsCatMod);
$totalRows_rsCatMod = mysql_num_rows($rsCatMod);

mysql_select_db($database_GSM_mobile, $GSM_mobile);
$query_rsCables = "SELECT cable_table.cab_cable_id, cable_table.cab_cable_name FROM cable_table";
$rsCables = mysql_query($query_rsCables, $GSM_mobile) or die(mysql_error());
$row_rsCables = mysql_fetch_assoc($rsCables);
$totalRows_rsCables = mysql_num_rows($rsCables);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
#Cable {
      position:absolute;
      width:200px;
      height:40px;
      z-index:1;
      left: 16px;
      top: 214px;
}
-->
</style>
<script type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
//-->
</script>
</head>

<body onLoad="MM_showHideLayers('Cable','','hide')">
<form id="add_model_frm" name="add_model_frm" method="POST" action="<?php echo $editFormAction; ?>">
  <p>Welcome to The Add Phone Model Category:</p>
  <p>
    <label>Enter the new model name:
    <input name="txt_name_model" type="text" id="txt_name_model" />
    </label>
</p>
  <p>Please Select The Category:
    <select name="Category" id="Category" onchange="TCN_reload(this)">
      <option selected="selected">Category</option>
    </select>
  </p>
  <p>Please Select The Brand:
    <select name="Brand" id="Brand" onchange="TCN_reload(this)">
      <option selected="selected">Brand</option>
    </select>
    <script language="JavaScript" type="text/javascript">
TCN_contents=new Array();
TCN_tempArray=new Array();
TCN_counter=0;
function TCN_addContent(str){
     TCN_contents[TCN_counter]=str;
     TCN_counter++;
}
function TCN_split(){
     TCN_arrayValues = new Array();
     for(i=0;i<TCN_contents.length;i++){
          TCN_arrayValues[i]=TCN_contents[i].split(separator);
          TCN_tempArray[0]=TCN_arrayValues;
     }
}
function TCN_makeSelValueGroup(){
     TCN_selValueGroup=new Array();
     var args=TCN_makeSelValueGroup.arguments;
     for(i=0;i<args.length;i++){
          TCN_selValueGroup[i]=args[i];
          TCN_tempArray[i]=new Array();
     }
}
function TCN_makeComboGroup(){
     TCN_comboGroup=new Array();
     var args=TCN_makeComboGroup.arguments;
     for(i=0;i<args.length;i++) TCN_comboGroup[i]=findObj(args[i]);
}
function TCN_setDefault(){
     for (i=TCN_selValueGroup.length-1;i>=0;i--){
          if(TCN_selValueGroup[i]!=""){
               for(j=0;j<TCN_contents.length;j++){
                    if(TCN_arrayValues[j][(i*2)+1]==TCN_selValueGroup[i]){
                         for(k=i;k>=0;k--){
                              if(TCN_selValueGroup[k]=="") TCN_selValueGroup[k]=TCN_arrayValues[j][(k*2)+1];
                         }
                    }
               }
          }
     }
}
function TCN_loadMenu(daIndex){
     var selectionMade=false;
     daArray=TCN_tempArray[daIndex];
     TCN_comboGroup[daIndex].options.length=0;
     for(i=0;i<daArray.length;i++){
          existe=false;
          for(j=0;j<TCN_comboGroup[daIndex].options.length;j++){
               if(daArray[i][(daIndex*2)+1]==TCN_comboGroup[daIndex].options[j].value) existe=true;
          }
          if(existe==false){
               lastValue=TCN_comboGroup[daIndex].options.length;
               TCN_comboGroup[daIndex].options[TCN_comboGroup[daIndex].options.length]=new Option(daArray[i][daIndex*2],daArray[i][(daIndex*2)+1]);
               if(TCN_selValueGroup[daIndex]==TCN_comboGroup[daIndex].options[lastValue].value){
                    TCN_comboGroup[daIndex].options[lastValue].selected=true;
                    selectionMade=true;
               }
          }
     }
     if(selectionMade==false) TCN_comboGroup[daIndex].options[0].selected=true;
}    
function TCN_reload(from){
     if(!from){
          TCN_split();
          TCN_setDefault();
          TCN_loadMenu(0);
          TCN_reload(TCN_comboGroup[0]);
     }else{
          for(j=0; j<TCN_comboGroup.length; j++){
               if(TCN_comboGroup[j]==from) index=j+1;
          }
          if(index<TCN_comboGroup.length){
               TCN_tempArray[index].length=0;
               for(i=0;i<TCN_comboGroup[index-1].options.length;i++){
                    if(TCN_comboGroup[index-1].options[i].selected==true){
                         for(j=0;j<TCN_tempArray[index-1].length;j++){
                              if(TCN_comboGroup[index-1].options[i].value==TCN_tempArray[index-1][j][(index*2)-1]) TCN_tempArray[index][TCN_tempArray[index].length]=TCN_tempArray[index-1][j];
                         }
                    }
               }
          TCN_loadMenu(index);
          TCN_reload(TCN_comboGroup[index]);
          }
     }
}
function findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
TCN_makeSelValueGroup("","");
TCN_makeComboGroup("Category","Brand");
 var separator="+#+";
<?php do{?>
TCN_addContent("<?php echo $row_rsCatMod['cat_category_name']; ?>+#+<?php echo $row_rsCatMod['cat_category_id']; ?>+#+<?php echo $row_rsCatMod['type_type_name']; ?>+#+<?php echo $row_rsCatMod['type_type_id']; ?>");
<?php } while ($row_rsCatMod = mysql_fetch_assoc($rsCatMod)); ?>
TCN_reload();

    </script>
  </p>
 
  <p>
    <label>Does this phone has a cable?
    <select name="cab_yes_no" id="cab_yes_no">
      <option>No</option>
      <option onSelect="MM_showHideLayers('Cable','','show')">Yes</option>
    </select>
    </label>
  </p>
  <p>&nbsp;  </p>
  <div id="Cable">
    <label>Select the Cable:
    <select name="cab_select" id="cab_select">
      <?php
do {  
?>
      <option value="<?php echo $row_rsCables['cab_cable_id']?>"><?php echo $row_rsCables['cab_cable_name']?></option>
      <?php
} while ($row_rsCables = mysql_fetch_assoc($rsCables));
  $rows = mysql_num_rows($rsCables);
  if($rows > 0) {
      mysql_data_seek($rsCables, 0);
       $row_rsCables = mysql_fetch_assoc($rsCables);
  }
?>
    </select>
    </label>
</div>
  <p>
    <label></label>
  </p>
  <label>
  <input name="submit_btn" type="submit" id="submit_btn" value="Add Model Now" />
  </label>
</form>
</body>
</html>
<?php
mysql_free_result($rsCatMod);

mysql_free_result($rsCables);
?>
0
 
Jason C. LevineNo oneCommented:
I think I misread the question:

As far as the database end goes, you can write a simple IF statement that blanks out the variable depending on the response

if ($_POST['cab_yes_no'] == No) {
cab_cable_id = 0;
}

Insert that before the INSERT query code.
0
 
dereksheahanAuthor Commented:
Thanks Jason, I'll give that a go now. Had a feeling you might be around and respond to me! Think its a somewhat similar question to one I asked you last night. Sorry, the post was closed so I should prob post it as a new question? http://www.experts-exchange.com/Web/WebDevSoftware/DreamWeaver/Q_21843443.html#16653156, just couldn't get that statement you suggested to work! Here in Ireland at 12:30 at night, really long days on this project :)
0
Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

 
Jason C. LevineNo oneCommented:
You could also use:

if ($_POST['cab_yes_no'] == No) {
$cab_cable_id = NULL;
}
0
 
dereksheahanAuthor Commented:
Cheers, no you didn't misread the question, the answered you just posted was also needed :)
0
 
Jason C. LevineNo oneCommented:
Yeah, I was little tired last night and I think I made that answer far harder that it was.  The above will suffice to kill any variable based on testing any other variable.

Ireland, eh?  I was in Dublin once for about a week 20 years ago.  Toured the Guiness brewery.  Good times, good times.

Sláinte!
0
 
dereksheahanAuthor Commented:
Good man, yeah haven't been in Dublin for a while, here in the south in Cork City (not much of a city really!). Congrats on son by the way, didn't know he was born only recently.
0
 
Jason C. LevineNo oneCommented:
He's the reason I can help you as often as I have been.  Normally, I'm working and can't answer posts as fast.  But I have family leave and new babies don't do much except sleep at this point...

Don't tell my wife, but I can't wait to go back to work.  I'm not cut out for this sit-at-home-and-wait-for-the-baby-to-poop thing.
0
 
dereksheahanAuthor Commented:
LOL, yeah I know I keep saying it but sincerely do appreciate all the help. I've been spending close to 12 hours a day on this project for the last week or so, couldn't imagine how much more if you weren't helpin me out!
0
 
Jason C. LevineNo oneCommented:
I've been where you are, man, so no thanks are necessary.

I just wish I knew about EE three or four years ago.
0
 
dereksheahanAuthor Commented:
Yeah, best site ever!.. Can't seem to put the right syntax on that statement you suggested. I tryed it before the insert statement (on the point marked HERE below) but it still entered into the DB. Is it okay what I'm trying to do this or am I completely off??

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

//HERE

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "add_model_frm")) {
  $insertSQL = sprintf("INSERT INTO model_table (mod_model_name, mod_type_id, mod_cable_id) VALUES (%s, %s, %s)",
                       GetSQLValueString($_POST['txt_name_model'], "text"),
                       GetSQLValueString($_POST['Brand'], "int"),
                       If {($_POST['cab_yes_no'] == No) {
$cab_cable_id = NULL; } Else { GetSQLValueString  $_POST['cab_select'], "int"))};

  mysql_select_db($database_GSM_mobile, $GSM_mobile);
  $Result1 = mysql_query($insertSQL, $GSM_mobile) or die(mysql_error());
}
0
 
Jason C. LevineNo oneCommented:
No, you can't screw with that $insertSQL variable that way...see how it is using backreferences (%s) to parse a list of other variables?  That syntax isn't interruptible.

//HERE

If ($_POST['cab_yes_no'] == "No") {
     $_POST['cab_select'] = NULL;
}

// If the posted variable cab_yes_no is "No", then set the POST variable cab_select to NULL.  Otherwise,
// do nothing

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "add_model_frm")) {
  $insertSQL = sprintf("INSERT INTO model_table (mod_model_name, mod_type_id, mod_cable_id) VALUES (%s, %s, %s)",
                       GetSQLValueString($_POST['txt_name_model'], "text"),
                       GetSQLValueString($_POST['Brand'], "int"),
                       GetSQLValueString  $_POST['cab_select'], "int"))};

  mysql_select_db($database_GSM_mobile, $GSM_mobile);
  $Result1 = mysql_query($insertSQL, $GSM_mobile) or die(mysql_error());
}
0
 
dereksheahanAuthor Commented:
Hi Jason,
Played around with the above for a good deal of time today but still no joy. In the server behaviour's panel there is a red exclaimation mark next to the insert record (add_model_frm, GS....) behaviour. I've when into this behaviour but all of the entries seem okay. The cable_id is still passed to the DB regardless of the cab_yes_no status. Also, the div layer is not displayed when the cable YES/NO is set to YES. Tried changing the visibility settings on that as well but no luck. Here's the way the page looks at the moment:
Cheers,
D

<?php require_once('../Connections/GSM_mobile.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "add_model_frm")) {
  $insertSQL = sprintf("INSERT INTO model_table (mod_model_name, mod_type_id, mod_cable_id) VALUES (%s, %s, %s)",
                       GetSQLValueString($_POST['txt_name_model'], "text"),
                       GetSQLValueString($_POST['Brand'], "int"),
                       GetSQLValueString($_POST['cab_select'], "int"));

  mysql_select_db($database_GSM_mobile, $GSM_mobile);
  $Result1 = mysql_query($insertSQL, $GSM_mobile) or die(mysql_error());
}

mysql_select_db($database_GSM_mobile, $GSM_mobile);
$query_rsCatMod = "SELECT category_table.cat_category_id, category_table.cat_category_name, type_table.type_type_id, type_table.type_type_name, type_table.type_category_id FROM category_table, type_table WHERE category_table.cat_category_id = type_table.type_category_id";
$rsCatMod = mysql_query($query_rsCatMod, $GSM_mobile) or die(mysql_error());
$row_rsCatMod = mysql_fetch_assoc($rsCatMod);
$totalRows_rsCatMod = mysql_num_rows($rsCatMod);

mysql_select_db($database_GSM_mobile, $GSM_mobile);
$query_rsCables = "SELECT cable_table.cab_cable_id, cable_table.cab_cable_name FROM cable_table";
$rsCables = mysql_query($query_rsCables, $GSM_mobile) or die(mysql_error());
$row_rsCables = mysql_fetch_assoc($rsCables);
$totalRows_rsCables = mysql_num_rows($rsCables);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
#Cable {
     position:absolute;
     width:200px;
     height:40px;
     z-index:1;
     left: 16px;
     top: 214px;
}
-->
</style>
<script type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
//-->
</script>
</head>

<body onLoad="MM_showHideLayers('Cable','','hide')">
<form id="add_model_frm" name="add_model_frm" method="POST" action="<?php echo $editFormAction; ?>">
  <p>Welcome to The Add Phone Model Category:</p>
  <p>
    <label>Enter the new model name:
    <input name="txt_name_model" type="text" id="txt_name_model" />
      
    </label>
</p>
  <p>Please Select The Category:
    <select name="Category" id="Category" onchange="TCN_reload(this)">
      <option selected="selected">Category</option>
    </select>
  </p>
  <p>Please Select The Brand:
    <select name="Brand" id="Brand" onchange="TCN_reload(this)">
      <option selected="selected">Brand</option>
    </select>
    <script language="JavaScript" type="text/javascript">
TCN_contents=new Array();
TCN_tempArray=new Array();
TCN_counter=0;
function TCN_addContent(str){
     TCN_contents[TCN_counter]=str;
     TCN_counter++;
}
function TCN_split(){
     TCN_arrayValues = new Array();
     for(i=0;i<TCN_contents.length;i++){
          TCN_arrayValues[i]=TCN_contents[i].split(separator);
          TCN_tempArray[0]=TCN_arrayValues;
     }
}
function TCN_makeSelValueGroup(){
     TCN_selValueGroup=new Array();
     var args=TCN_makeSelValueGroup.arguments;
     for(i=0;i<args.length;i++){
          TCN_selValueGroup[i]=args[i];
          TCN_tempArray[i]=new Array();
     }
}
function TCN_makeComboGroup(){
     TCN_comboGroup=new Array();
     var args=TCN_makeComboGroup.arguments;
     for(i=0;i<args.length;i++) TCN_comboGroup[i]=findObj(args[i]);
}
function TCN_setDefault(){
     for (i=TCN_selValueGroup.length-1;i>=0;i--){
          if(TCN_selValueGroup[i]!=""){
               for(j=0;j<TCN_contents.length;j++){
                    if(TCN_arrayValues[j][(i*2)+1]==TCN_selValueGroup[i]){
                         for(k=i;k>=0;k--){
                              if(TCN_selValueGroup[k]=="") TCN_selValueGroup[k]=TCN_arrayValues[j][(k*2)+1];
                         }
                    }
               }
          }
     }
}
function TCN_loadMenu(daIndex){
     var selectionMade=false;
     daArray=TCN_tempArray[daIndex];
     TCN_comboGroup[daIndex].options.length=0;
     for(i=0;i<daArray.length;i++){
          existe=false;
          for(j=0;j<TCN_comboGroup[daIndex].options.length;j++){
               if(daArray[i][(daIndex*2)+1]==TCN_comboGroup[daIndex].options[j].value) existe=true;
          }
          if(existe==false){
               lastValue=TCN_comboGroup[daIndex].options.length;
               TCN_comboGroup[daIndex].options[TCN_comboGroup[daIndex].options.length]=new Option(daArray[i][daIndex*2],daArray[i][(daIndex*2)+1]);
               if(TCN_selValueGroup[daIndex]==TCN_comboGroup[daIndex].options[lastValue].value){
                    TCN_comboGroup[daIndex].options[lastValue].selected=true;
                    selectionMade=true;
               }
          }
     }
     if(selectionMade==false) TCN_comboGroup[daIndex].options[0].selected=true;
}    
function TCN_reload(from){
     if(!from){
          TCN_split();
          TCN_setDefault();
          TCN_loadMenu(0);
          TCN_reload(TCN_comboGroup[0]);
     }else{
          for(j=0; j<TCN_comboGroup.length; j++){
               if(TCN_comboGroup[j]==from) index=j+1;
          }
          if(index<TCN_comboGroup.length){
               TCN_tempArray[index].length=0;
               for(i=0;i<TCN_comboGroup[index-1].options.length;i++){
                    if(TCN_comboGroup[index-1].options[i].selected==true){
                         for(j=0;j<TCN_tempArray[index-1].length;j++){
                              if(TCN_comboGroup[index-1].options[i].value==TCN_tempArray[index-1][j][(index*2)-1]) TCN_tempArray[index][TCN_tempArray[index].length]=TCN_tempArray[index-1][j];
                         }
                    }
               }
          TCN_loadMenu(index);
          TCN_reload(TCN_comboGroup[index]);
          }
     }
}
function findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
TCN_makeSelValueGroup("","");
TCN_makeComboGroup("Category","Brand");
 var separator="+#+";
<?php do{?>
TCN_addContent("<?php echo $row_rsCatMod['cat_category_name']; ?>+#+<?php echo $row_rsCatMod['cat_category_id']; ?>+#+<?php echo $row_rsCatMod['type_type_name']; ?>+#+<?php echo $row_rsCatMod['type_type_id']; ?>");
<?php } while ($row_rsCatMod = mysql_fetch_assoc($rsCatMod)); ?>
TCN_reload();

    </script>
  </p>
 
  <p>
    <label>Does this phone has a cable?
    <select name="cab_yes_no" id="cab_yes_no">
      <option>No</option>
      <option onSelect="MM_showHideLayers('Cable','','show')">Yes</option>
    </select>
    </label>
  </p>
  <p>&nbsp;  </p>
  <div id="Cable">
    <label>Select the Cable:
    <select name="cab_select" id="cab_select">
      <?php
do {  
?>
      <option value="<?php echo $row_rsCables['cab_cable_id']?>"><?php echo $row_rsCables['cab_cable_name']?></option>
      <?php
} while ($row_rsCables = mysql_fetch_assoc($rsCables));
  $rows = mysql_num_rows($rsCables);
  if($rows > 0) {
      mysql_data_seek($rsCables, 0);
       $row_rsCables = mysql_fetch_assoc($rsCables);
  }
?>
    </select>
    </label>
</div>
  <p>
    <label></label>
  </p>
  <label>
  <input name="submit_btn" type="submit" id="submit_btn" value="Add Model Now" />
  </label>
  <input type="hidden" name="model_id_auto" value="">
</form>
</body>
</html>
<?php
mysql_free_result($rsCatMod);

mysql_free_result($rsCables);
?>
0
 
Jason C. LevineNo oneCommented:
>> In the server behaviour's panel there is a red exclaimation mark next to the insert record (add_model_frm, GS....)

That will happen when you insert your own code into something DW wrote.  Just ignore it.

>> The cable_id is still passed to the DB regardless of the cab_yes_no status.

Where is the if statement that assigns cable_id to null if cab_yes_no = no?  That is the true answer to this problem.  The show-hide layers trick won't do anything except hide the field, which is why I thought I misread the question initially.

>> Also, the div layer is not displayed when the cable YES/NO is set to YES

Change the onSelect handler to onClick.  I always f_ck that up...
0
 
dereksheahanAuthor Commented:
LOL, sorry took it out and put it back in so many times if forgot it in the post I just sent you. I just put it back in but no go still. Also, changed onSelect to onClick but still no visual on that front.  Here's the full page
<?php require_once('../Connections/GSM_mobile.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
If ($_POST['cab_yes_no'] == "No") {
     $_POST['cab_select'] = NULL;
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "add_model_frm")) {
  $insertSQL = sprintf("INSERT INTO model_table (mod_model_name, mod_type_id, mod_cable_id) VALUES (%s, %s, %s)",
                       GetSQLValueString($_POST['txt_name_model'], "text"),
                       GetSQLValueString($_POST['Brand'], "int"),
                       GetSQLValueString($_POST['cab_select'], "int"));

  mysql_select_db($database_GSM_mobile, $GSM_mobile);
  $Result1 = mysql_query($insertSQL, $GSM_mobile) or die(mysql_error());
}

mysql_select_db($database_GSM_mobile, $GSM_mobile);
$query_rsCatMod = "SELECT category_table.cat_category_id, category_table.cat_category_name, type_table.type_type_id, type_table.type_type_name, type_table.type_category_id FROM category_table, type_table WHERE category_table.cat_category_id = type_table.type_category_id";
$rsCatMod = mysql_query($query_rsCatMod, $GSM_mobile) or die(mysql_error());
$row_rsCatMod = mysql_fetch_assoc($rsCatMod);
$totalRows_rsCatMod = mysql_num_rows($rsCatMod);

mysql_select_db($database_GSM_mobile, $GSM_mobile);
$query_rsCables = "SELECT cable_table.cab_cable_id, cable_table.cab_cable_name FROM cable_table";
$rsCables = mysql_query($query_rsCables, $GSM_mobile) or die(mysql_error());
$row_rsCables = mysql_fetch_assoc($rsCables);
$totalRows_rsCables = mysql_num_rows($rsCables);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
#Cable {
     position:absolute;
     width:200px;
     height:40px;
     z-index:1;
     left: 16px;
     top: 214px;
}
-->
</style>
<script type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
//-->
</script>
</head>

<body onLoad="MM_showHideLayers('Cable','','hide')">
<form id="add_model_frm" name="add_model_frm" method="POST" action="<?php echo $editFormAction; ?>">
  <p>Welcome to The Add Phone Model Category:</p>
  <p>
    <label>Enter the new model name:
    <input name="txt_name_model" type="text" id="txt_name_model" />
      
    </label>
</p>
  <p>Please Select The Category:
    <select name="Category" id="Category" onchange="TCN_reload(this)">
      <option selected="selected">Category</option>
    </select>
  </p>
  <p>Please Select The Brand:
    <select name="Brand" id="Brand" onchange="TCN_reload(this)">
      <option selected="selected">Brand</option>
    </select>
    <script language="JavaScript" type="text/javascript">
TCN_contents=new Array();
TCN_tempArray=new Array();
TCN_counter=0;
function TCN_addContent(str){
     TCN_contents[TCN_counter]=str;
     TCN_counter++;
}
function TCN_split(){
     TCN_arrayValues = new Array();
     for(i=0;i<TCN_contents.length;i++){
          TCN_arrayValues[i]=TCN_contents[i].split(separator);
          TCN_tempArray[0]=TCN_arrayValues;
     }
}
function TCN_makeSelValueGroup(){
     TCN_selValueGroup=new Array();
     var args=TCN_makeSelValueGroup.arguments;
     for(i=0;i<args.length;i++){
          TCN_selValueGroup[i]=args[i];
          TCN_tempArray[i]=new Array();
     }
}
function TCN_makeComboGroup(){
     TCN_comboGroup=new Array();
     var args=TCN_makeComboGroup.arguments;
     for(i=0;i<args.length;i++) TCN_comboGroup[i]=findObj(args[i]);
}
function TCN_setDefault(){
     for (i=TCN_selValueGroup.length-1;i>=0;i--){
          if(TCN_selValueGroup[i]!=""){
               for(j=0;j<TCN_contents.length;j++){
                    if(TCN_arrayValues[j][(i*2)+1]==TCN_selValueGroup[i]){
                         for(k=i;k>=0;k--){
                              if(TCN_selValueGroup[k]=="") TCN_selValueGroup[k]=TCN_arrayValues[j][(k*2)+1];
                         }
                    }
               }
          }
     }
}
function TCN_loadMenu(daIndex){
     var selectionMade=false;
     daArray=TCN_tempArray[daIndex];
     TCN_comboGroup[daIndex].options.length=0;
     for(i=0;i<daArray.length;i++){
          existe=false;
          for(j=0;j<TCN_comboGroup[daIndex].options.length;j++){
               if(daArray[i][(daIndex*2)+1]==TCN_comboGroup[daIndex].options[j].value) existe=true;
          }
          if(existe==false){
               lastValue=TCN_comboGroup[daIndex].options.length;
               TCN_comboGroup[daIndex].options[TCN_comboGroup[daIndex].options.length]=new Option(daArray[i][daIndex*2],daArray[i][(daIndex*2)+1]);
               if(TCN_selValueGroup[daIndex]==TCN_comboGroup[daIndex].options[lastValue].value){
                    TCN_comboGroup[daIndex].options[lastValue].selected=true;
                    selectionMade=true;
               }
          }
     }
     if(selectionMade==false) TCN_comboGroup[daIndex].options[0].selected=true;
}    
function TCN_reload(from){
     if(!from){
          TCN_split();
          TCN_setDefault();
          TCN_loadMenu(0);
          TCN_reload(TCN_comboGroup[0]);
     }else{
          for(j=0; j<TCN_comboGroup.length; j++){
               if(TCN_comboGroup[j]==from) index=j+1;
          }
          if(index<TCN_comboGroup.length){
               TCN_tempArray[index].length=0;
               for(i=0;i<TCN_comboGroup[index-1].options.length;i++){
                    if(TCN_comboGroup[index-1].options[i].selected==true){
                         for(j=0;j<TCN_tempArray[index-1].length;j++){
                              if(TCN_comboGroup[index-1].options[i].value==TCN_tempArray[index-1][j][(index*2)-1]) TCN_tempArray[index][TCN_tempArray[index].length]=TCN_tempArray[index-1][j];
                         }
                    }
               }
          TCN_loadMenu(index);
          TCN_reload(TCN_comboGroup[index]);
          }
     }
}
function findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
TCN_makeSelValueGroup("","");
TCN_makeComboGroup("Category","Brand");
 var separator="+#+";
<?php do{?>
TCN_addContent("<?php echo $row_rsCatMod['cat_category_name']; ?>+#+<?php echo $row_rsCatMod['cat_category_id']; ?>+#+<?php echo $row_rsCatMod['type_type_name']; ?>+#+<?php echo $row_rsCatMod['type_type_id']; ?>");
<?php } while ($row_rsCatMod = mysql_fetch_assoc($rsCatMod)); ?>
TCN_reload();

    </script>
  </p>
 
  <p>
    <label>Does this phone has a cable?
    <select name="cab_yes_no" id="cab_yes_no">
      <option>No</option>
      <option onClick="MM_showHideLayers('Cable','','show')">Yes</option>
    </select>
    </label>
  </p>
  <p>&nbsp;  </p>
  <div id="Cable">
    <label>Select the Cable:
    <select name="cab_select" id="cab_select">
      <?php
do {  
?>
      <option value="<?php echo $row_rsCables['cab_cable_id']?>"><?php echo $row_rsCables['cab_cable_name']?></option>
      <?php
} while ($row_rsCables = mysql_fetch_assoc($rsCables));
  $rows = mysql_num_rows($rsCables);
  if($rows > 0) {
      mysql_data_seek($rsCables, 0);
       $row_rsCables = mysql_fetch_assoc($rsCables);
  }
?>
    </select>
    </label>
</div>
  <p>
    <label></label>
  </p>
  <label>
  <input name="submit_btn" type="submit" id="submit_btn" value="Add Model Now" />
  </label>
  <input type="hidden" name="model_id_auto" value="">
</form>
</body>
</html>
<?php
mysql_free_result($rsCatMod);

mysql_free_result($rsCables);
?>
0
 
Jason C. LevineNo oneCommented:
onClick works for me in Firefox but IE appears to choke on it and I don't know why...sorry.

What is being submitted to the table even when the value should be set to null?  I can't test the PHP part of it.
0
 
dereksheahanAuthor Commented:
Hi Jason,
yeah thats weird, FF and IE seem to give a lot of problems alright where one thing will work on one but not on the other. The value that is submitted is a cable_id of one (which obviously is the first value in the drop-down that is invisible).
0
 
Jason C. LevineNo oneCommented:
Crap.

Maybe change it to just ""  ...the NULL may be throwing off the GetSQLValueString function:

If ($_POST['cab_yes_no'] == "No") {
     $_POST['cab_select'] = "";
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "add_model_frm")) {
  $insertSQL = sprintf("INSERT INTO model_table (mod_model_name, mod_type_id, mod_cable_id) VALUES (%s, %s, %s)",
                       GetSQLValueString($_POST['txt_name_model'], "text"),
                       GetSQLValueString($_POST['Brand'], "int"),
                       GetSQLValueString($_POST['cab_select'], "int"));

  mysql_select_db($database_GSM_mobile, $GSM_mobile);
  $Result1 = mysql_query($insertSQL, $GSM_mobile) or die(mysql_error());
}
0
 
dereksheahanAuthor Commented:
Thanks, I'll check that in the morning. Getting pulled out the door here! Talk to ya later :)
0
 
dereksheahanAuthor Commented:
Great! ,the cable id is no longer passed. In regard to the show/hide region, I could post a pointer for this problem in the javascript section. As someone on this site said to me previously however (probably you!), javascript can be disabled by the browser and therefore not useful if I want to use it on a page accessabile to the public. What are the other options I have available to me for this problem before I spend more time on the javascript solution?
Thanks,
D
0
 
Jason C. LevineNo oneCommented:
I can think of two possible responses

1. If the PHP is killing the variable anyway, who really cares if it is visible or not?

2. Even though javascript can be disabled, in practice very few people actually disable it...too much of the internet stops working.

Not sure how else to go here...the javascript guys can fix the problem if you want them to...I don't pretend to know that much about JS.

0
 
dereksheahanAuthor Commented:
Okay thanks, I guess I'll go with the javascript solution and post a question in their area.
D
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 11
  • 11
Tackle projects and never again get stuck behind a technical roadblock.
Join Now