Jump to content

form issue


laxi

Recommended Posts

Hello everyone,

 

I am building up a site and I have a form that is kind off tricky.

 

I have 3 depenendable select boxes in my form for category,first-subcategory,second-subcategory that been written in using javascript.

 

But the form itself has other elements that needs to be parsed to a php scripts.

 

The 3 dependable select boxes has no action attribute, ie action=" " for it to work according to the written javascript and I have copied this script from a forum help section. I had to integrate this 3 dependable select boxes into my original form which parses to a action="inventory.php" script.

 

When I integrate the 3 dependable boxes into my form that parses to action="inventory.php" the dependable boxes dont work for first-subcategory,second-subcategory as the javascript requires action=" " and not action="inventory.php".

 

However i need the form to be parsed to the "inventory.php" script. 

 

below is my code..Can somebody advise and make this work for me..

 

 

 

 

<?php
session_start(); 
if (!isset($_SESSION["manager"])){
header("location:admin_login.php");
exit();
}
?>
<?php
/* checking if this is a valid session in database  */
$managerID=preg_replace('#[^0-9]#','',$_SESSION["id"]);
$username=preg_replace('#[^0-9a-z]#i','',$_SESSION["manager"]);
$password=preg_replace('#[^0-9a-z]#i','',$_SESSION["password"]);
 
include "../storescripts/connect_to_mysql.php";  /* connect to database */
/* do a query on database */
$sql=mysql_query("SELECT * FROM admin WHERE id='$managerID' AND username='$username' AND password='$password'");
$row=mysql_num_rows($sql);/* counting the number of rows returned from above query */
 
if($row==0)
{ echo "You are not authorised to enter this region as your credentials are not valid on our database";
exit(); }
?>
<?php
/* list all the products for viewing*/
$product_list="";
$sql=mysql_query("SELECT * FROM products");
$count=mysql_num_rows($sql);
if ($count>0)
{ while($row = mysql_fetch_array($sql)){
       $id=$row["id"];
  $product_name=$row["product_name"];
  $price=$row["price"];
  $List1=$row["List1"];
  $List2=$row["List2"];
  $List3=$row["List3"];
  $date_added=$row["date_added"];
  
$product_list .= "$id- $product_name- $price- $List1- $List2- $List3-$date_added  <a href='#'>edit</a> •<a href='#'>delete</a> <br>";
}
}
else
{
$product_list = "You dont have any products listed in your store yet";
}
?>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Manage Inventory</title>
<link rel="stylesheet" href="../style/style.css" type="text/css" media="screen"/>
<script type="text/javascript">
 
/*
Triple Combo Script Credit
Visit http://javascriptkit.com for this and over 400+ other scripts
*/
 
var categories = [];
categories["startList"] = ["CLOTHING","ELECTRONICS","AUTOMOBILES"]
categories["CLOTHING"] = ["MEN","WOMEN","KIDS", "FEATURED STORES CLOTHING","OFFERS CLOTHING"];
categories["ELECTRONICS"] = ["CAR/AUTO ELECTRONICS & GPS","CAMERA AND PHOTO","CELL PHONES AND ACCESSORIES","MP3 PLAYERS AND ACCESSORIES","TV,HOME THEATRE,AUDIO/VIDEO","MUSICAL INSTRUMENTS AND ACCESSORIES","VIDEO GAMES"];
categories["AUTOMOBILES"] = ["CAR","MOTORCYCLE"];
categories["MEN"] = ["T-shirts","Casual & Party Wear Shirts","Formal Shirts","Jeans","Cargos, Shorts & 3/4ths","Trousers","Inner & Sleep Wear","Rainwear","Sports Wear","Accessories & Combo Sets","Suits & Blazers","BRANDS MEN"];
categories["WOMEN"] = ["Dresses & Skirts","Ethnic Wear","Shirts, Tops & Tunics","Polos & T-shirts","Jeans & Shorts", "Leggings & Jeggings","Trousers & Capris","Lingerie & Sleepwear","Accessories","BRANDS WOMEN"];
categories["KIDS"] = ["BOYS","GIRLS","INFANTS"];
categories["FEATURED STORES"] = ["For Men", "For Women", "For Kids"];
categories["OFFERS"] = ["Featured Deals", "SALE"];
 
categories["CAR/AUTO ELECTRONICS & GPS"] = ["Car Audio","Car Stereo", "Car Speakers", "Car Amplifiers","Car Subwoofers","Car Video", "Satellite Radio", "CB Radio","OTHER Car Audio & Video ","Alarm Systems", "Key-less entry", "Remote Starters", "Vehicle Back-Up Cameras","Steering Wheel Locking  ","Radar Detectors", "OTHER Car Safety & Security", "Vehicle GPS" ,"GPS Mapping Software", "GPS Trackers", "GPS Systems Accessories", "Sport & Handheld GPS", "Boating GPS","OTHER GPS & Navigation",];
categories["CAMERA AND PHOTO"] = ["Digital SLR","Point & Shoot","Advanced Point & Shoot", "Camcorder", "Mirrorless ","Brands", "SLR ACCESSORIES", "Lenses by brands", "Lens Cleaners","Lens Caps  ","Filters", "Flashes", "Memory Cards" , "Tripods", "Camera Bags", "Binoculars & Optics", "Digital Photoframes", "FEATURED STORES","OFFERS"];
categories["CELL PHONES AND ACCESSORIES"] = ["Brand cell phones","Samsung","Micromax", "Nokia", "Sony ","HTC", "Apple", "BlackBerry", "FEATURED STORES CELL PHONES AND ACCESSORIES","OFFERS CELL PHONES AND ACCESSORIES ","SERVICES"];
categories["MP3 PLAYERS AND ACCESSORIES"] = ["Under 1GB","1 to 4 GB","5 to 24 GB", "25 to 60 GB","61 to 120 GB",        "Over 120 GB","ipod", "MP3 PLAYERS","SPEAKER SYSTEMS","MP3 ACCESSORIES","HEADPHONES", "CASES"];
categories["TV,HOME THEATRE,AUDIO/VIDEO"] = ["Home Theater Systems","Compact & Portable Audio","Speakers", "Home Audio Accessories","Headphones",        "HDTVs","Blu-ray Players and Projectors", "OTHER HOME THEATER EQPMTS "];
categories["MUSICAL INSTRUMENTS AND ACCESSORIES"] = ["Guitars","Bass Guitars","Drums & Percussion", "Keyboards", "Band & Orchestra","Folk & World Instruments","Instrument Accessories", "Studio Recording Equipment ","Top Deals"];
categories["VIDEO GAMES"] = ["PlayStation 4","PlayStation 3", "Xbox One", "Xbox 360","Sony PSP","Mac","Sony PSP", "Digital Games", "Best-Selling Video Games","OTHER GAMES AND ACCESSORIES", ];
 
 
 
categories["CAR"] = ["MAKE","NEW","USED", "OTHERS"];
 
categories["MOTORCYCLE"] = ["Ducati","BMW", "Shop by Type"]
 
var nLists = 3; // number of select lists in the set
 
function fillSelect(currCat,currList){
var step = Number(currList.name.replace(/\D/g,""));
for (i=step; i<nLists+1; i++) {
document.forms['tripleplay']['List'+i].length = 1;
document.forms['tripleplay']['List'+i].selectedIndex = 0;
}
var nCat = categories[currCat];
for (each in nCat) {
var nOption = document.createElement('option'); 
var nData = document.createTextNode(nCat[each]); 
nOption.setAttribute('value',nCat[each]); 
nOption.appendChild(nData); 
currList.appendChild(nOption); 
}
 
 
 
function init() {
fillSelect('startList',document.forms['tripleplay']['List1'])
}
 
navigator.appName == "Microsoft Internet Explorer" ? attachEvent('onload', init, false) : addEventListener('load', init, false);
 
</script> 
</head>
 
<body style="margin: 0px; padding: 0px; height: 100%;  text-align: center; >
<div align="center"  id= "mainWrapper" margin-left= 0px;>
<?php include_once("../template_header.php");?>
 
<div id= "pageContent">
  <h1 align="center"> Manage Inventory</h1>
  <div align= "right" style=" margin: 50px" ><a href="inventory_list.php#inventoryForm">+Click here to add inventory to the store </a></div>
  <p><?php echo $product_list; ?></p>
  <a name="inventoryForm" id="inventoryForm"></a>
  <h2 align="center"> Add  Inventory Items to the store</h2>
  <form action="" method="post" enctype="multipart/form-data" name="tripleplay"><table width="87%" border="1">
    <tr>
      <td align="right" width="29%">Product Name </td>
      <td width="43%"><input name="product_name" type="text" id="product_name"/></td>
      <td width="28%"><label id="product_name" > </label></td>
    </tr>
    <tr>
      <td align="right">Price  </td>
      <td> $ <input name="price" type="text" id="price"/></td>
      <td><label id="price"> </label></td>
    </tr>
    <tr>
      <td align="right">Category  </td>
      <td><select name='List1' onchange="fillSelect(this.value,this.form['List2'])">
<option selected>Make a selection</option>
</select></td>
      <td><label id="category"> </label></td>
    </tr>
    <tr>
      <td align="right">First-Subcategory  </td>
      <td> <select name='List2' onchange="fillSelect(this.value,this.form['List3'])">
<option selected>Make a selection</option>
</select></td>
      <td><label id="first-subcategory"> </label></td>
    </tr>
    <tr>
      <td align="right">Second-Subcategory  </td>
      <td><select name='List3' onchange="getValue(this.value, this.form['List2'].value, 
this.form['List1'].value)">
<option selected >Make a selection</option>
</select></td>
      <td><label id="second-subcategory"> </label></td>
    </tr>
    <tr>
      <td align="right">Details   </td>
      <td><textarea name="details" cols="55" rows="10"> </textarea></td>
      <td><label id="details"> </label></td>
    </tr>
    <tr>
      <td align="right">Upload Product Image  </td>
      <td> <input name="imagefile" type="file" /></td>
      <td><label id="imagefile"> </label></td>
    </tr>
    <tr>
      <td> </td>
      <td><input name="submit" type="submit" value="submit" />  <input name="reset" type="reset" value="reset" /></td>
      <td> </td>
    </tr>
  </table></form>
  <p> </p>
  <p> </p>
</div>
<?php include_once("../template_footer.php");?>
 
</div>
<p> </p>
</body>
</html>
 
 
Thanks in advance
Link to comment
Share on other sites

in case the OP revisits this thread. there are several reasons why no one attempted to reply to this thread -

 

1) it is in the wrong forum section. it has nothing to do with Php Math Help.

 

2) it is the same task/problem as your previous thread and your follow-on thread. you seem to be just trying different things, throwing code and forum threads away. no one is going to try and understand what your code is doing in order to help you with it if you don't stick to the same thread for your task.

 

3) you didn't post the code using the forum's


bbcode tags (the edit form's <> button).

 

4) i doubt anyone can understand the statement of the question/problem. you need to just post the relevant facts.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.