Jump to content

harryuk

Members
  • Posts

    19
  • Joined

  • Last visited

    Never

Posts posted by harryuk

  1. Yes exactly. Under the sub-category section all the option tags have no values until an item is selected on the category section. Usually you would have values already in the option tag so you can add your $_POST function in order to send all form info to another page. But in this instance i do not have any values to be able to add a $_POST function?!?!

  2. Hi,

    I would like to use the $_POST function for the sub-category section of the form. The problem i am having is how i can do this as i am using javascript to automatically update the sub-category section when a item is selected in the category section. So where and how would i put the $_POST function so i can echo the form info including what sub-category item i selected out on my index.php page.

     

    I hope that makes sense. Please help

    Thank you

    team = new Array(
    new Array(
    new Array("Toesavers", 39482304),	
    new Array("Dr. Martens Industrial", 34802389),
    new Array("Himalayan", 39823498),
    new Array("Caterpillar", 87587343),
    new Array("Timberland", 68798735)
    ),
    new Array(
    new Array("Hand Protection", 23840238),
    new Array("Eye & Face Protection", 92390484),
    new Array("WeatherWear", 29048203),
    new Array("Head Protection", 94098230),
    new Array("Hearing Protection", 39234923),
    new Array("Respiratory Protection", 29345423)
    ),
    );
    function fillSelectFromArray(selectCtrl, itemArray, goodPrompt, badPrompt, defaultItem) {
    var i, j;
    var prompt;
    // empty existing items
    for (i = selectCtrl.options.length; i >= 0; i--) {
    selectCtrl.options[i] = null;
    }
    prompt = (itemArray != null) ? goodPrompt : badPrompt;
    if (prompt == null) {
    j = 0;
    }
    else {
    selectCtrl.options[0] = new Option(prompt);
    j = 1;
    }
    if (itemArray != null) {
    // add new items
    for (i = 0; i < itemArray.length; i++) {
    selectCtrl.options[j] = new Option(itemArray[i][0]);
    if (itemArray[i][1] != null) {
    selectCtrl.options[j].value = itemArray[i][1];
    }
    j++;
    }
    selectCtrl.options[0].selected = true;
       }
    }
    <form>
    <select name="Make" onchange="fillSelectFromArray(this.form.Team, ((this.selectedIndex == -1) ? null : team[this.selectedIndex-1]));">
    <option value="-1" selected="selected">Select Category</option>
    <option value="1">Footwear</option>
    <option value="2">PPE</option>
    <option value="3">Ladders</option>
    </select></label>
      <label>
        Sub-Category
      <select name="Team">
      <option></option>
    <option></option>
    <option></option>
    <option></option>
    <option></option>
    <option></option>
    </select></label>
    </form>
    

  3. Hello follow PHP'ers

     

    I have a form stored in my admin directory and a public temple named Products. I have a link on my header to access it!!!

     

    I am using abit of Java script so when a product is selected (admin side) from a drop down menu named category it updates the sub-category drop down menu that is all working fine. What i cant work out is when a product is selected from the sub-category and the form is submited how to put all the stored data on to the public template products and how to what ever is selected from the sub-category echoes out under a header on the public template named what ever was selected.

     

    Example

    
    $product_glasses = "";
    $sql = mysql_query("SELECT * FROM products ORDER BY date_added DESC");
    $productCount = mysql_num_rows($sql);
    if ($productCount > 0) {
    while($row = mysql_fetch_array($sql)){ 
                 $id = $row["id"];
    		 $product_name = $row["product_name"];
    		 $price = $row["price"];
    		 $date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));
    		 $product_list .= "Product ID: $id - <strong>$product_name</strong> - $$price - $category - $subcategory       • <a href='inventory_list.php?deleteid=$id'>delete</a><br />";
        }
    } else {
    $product_glasses = "You have no products listed in your store yet";
    }
    ?>
        <form action="inventory_list.php" enctype="multipart/form-data" name="myForm" id="myform" method="post">
        <table width="90%" border="0" cellspacing="0" cellpadding="6">
          <tr>
            <td width="20%" align="right">Product Name</td>
            <td width="80%"><label>
              <input name="product_name" type="text" id="product_name" size="64" />
            </label></td>
          </tr>
          <tr>
            <td align="right">Product Price</td>
            <td><label>
             £
              <input name="price" type="text" id="price" size="12" />
            </label></td>
          </tr>
          <tr>
            <td align="right">Category</td>
            <td><label>
              <select name="category" id="category">
              <option value="Clothing">Clothing</option>
              <option value="accessories">accessories</option>
    
              </select>
            </label></td>
          </tr>
          <tr>
            <td align="right">Subcategory</td>
            <td><select name="subcategory" id="subcategory">
            <option value=""></option>
              <option value="watches">watches</option>
              <option value="glasses">glasses</option>
              <option value="Shirts">Shirts</option>
              </select></td>
          </tr>
          <tr>
            <td align="right">Product Details</td>
            <td><label>
              <input type="submit" name="button" id="button" value="Add This Item Now" />
            </label></td>
          </tr>
        </table>
        </form>
    

     

    Then have that echoed out in the public template products like so.

     

    
    <body>
    
    Glasses
    <hr>
    <? echo '$product_glasses' ?>
    <br />
    <br />
    watches
    <hr>
    <? echo '$product_watches' ?> /////////How i would be able to echo this out ???? I know i have do perform some code under the sub-category section but i just dont know what??
    
    

    PLEASE HELP

    Thanks

  4. Hello, I am studing PHP & mysql, And have come up stuck on a particular area??

     

    I am designing a admin page to be able to submit info on to a public template.

     

        <form action="inventory_list.php" enctype="multipart/form-data" name="myform" id="myform" method="post">
        <table width="90%" border="0" cellspacing="0" cellpadding="6">
          <tr>
            <td width="20%" align="right">Name</td>
            <td width="80%"><label>
              <input name="product_name" type="text" id="product_name" size="64" />
            </label></td>
          </tr>
          <tr>
            <td height="39" align="right">Category</td>
    <td><label>
    <select name="Make">
    <option value="-1" selected="selected">Select Category</option>
    <option value="1">Singers</option>
    </select></label>
      <label>
        Sub-Category
      <select name="Team">
    <option>Steve Brooks</option>
    <option>Elvis</option>
    <option>Coolio</option>
    </select></label>
    </td></tr>
          <tr>
            <td align="right">Details</td>
            <td><label>
              <textarea name="details" id="details" cols="64" rows="5"></textarea>
            </label></td>
          </tr>
          <tr>
            <td align="right">Image</td>
            <td><label>
              <input type="file" name="fileField" id="fileField" />
            </label></td>
          </tr>      
          <tr>
            <td> </td>
            <td><label>
              <input type="submit" name="button" id="button" value="Add This Item Now" />
            </label></td>
          </tr>
        </table>
        </form>
        <br />
      <br />
      </div>
    </div>
    </body>
    </html>

     

     

    Once selected a sub category i want it submitted to a individual page.

    for example if elvis is selected in sub category in the admin area i would like all the info from the form echoed out in a public template named elvis.

     

  5. Hello people!!

     

    I am currently designing a E-Commence Website and have come stuck of the admin side.

     

    I have designed a form with all the fields i require, I have a drop down menu with different categories i intend to use i.e clothes, shoes, hats etc,

     

    Now i am trying to put these categories on the admin side in to the correct categories on the public template side.

     

    i.e all clothing to be displayed under'clothing' on index page??

     

    please help? :-[

     

    Code i have wrote up.

     

        <form action="inventory_edit.php" enctype="multipart/form-data" name="myForm" id="myform" method="post">

        <table width="90%" border="0" cellspacing="0" cellpadding="6">

          <tr>

            <td width="20%" align="right">Product Name</td>

            <td width="80%"><label>

              <input name="product_name" type="text" id="product_name" size="64" value="<?php echo $product_name; ?>" />

            </label></td>

          </tr>

          <tr>

            <td align="right">Product Price</td>

            <td><label>

              $

              <input name="price" type="text" id="price" size="12" value="<?php echo $price; ?>" />

            </label></td>

          </tr>

          <tr>

            <td align="right">Category</td>

            <td><label>

            <select name="category" id="category">

              <option value="workwear" selected="selected" onclick="">Workwear</option>

              <option value="footwear">Footwear</option>

              <option value="safety">Safety</option>

              <option value="ladders">Ladders</option>

              </select>

            </label></td>

          </tr>

          <tr>

            <td align="right">Product Details</td>

            <td><label>

              <textarea name="details" id="details" cols="64" rows="5"><?php echo $details; ?></textarea>

            </label></td>

          </tr>

          <tr>

            <td align="right">Product Image</td>

            <td><label>

              <input type="file" name="fileField" id="fileField" />

            </label></td>

          </tr>     

          <tr>

            <td> </td>

            <td><label>

              <input name="thisID" type="hidden" value="<?php echo $targetID; ?>" />

              <input type="submit" name="button" id="button" value="Make Changes" />

            </label></td>

          </tr>

        </table>

        </form>

    </body>

    </html>

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