0

I am trying to get the value of my input upon a click of the button. I am able to get the value of text box but not for drop down list and number box (input type=number).

How should I go about doing it?

Below is my code:

          <div class=accountMain>
            <div align=left>
            <table>
                <tr>
                    <td>Product Code:</td>
                    <td>EX00001</td>
                </tr>
                <tr>
                    <td>Product Name:</td>
                    <td><input type=text name=productName value=$productName></td>
                </tr>

                <tr>
                    <td>Description:</td>
                    <td><input type=text name=productDesc value=$productDesc></td>
                </tr>

                <tr>
                    <td>Price: SGD$</td>
                    <td><input type=text name=unitPrice value=$unitPrice></td>
                </tr>

                <tr>
                    <td>Quantity Available:</td>
                    <td><input type=text name=qty value=$qty></td>
                </tr>

                <tr>
                    <td>Size <br>
                    (Only applicable for T-Shirt):</td>
                    <td><select>
                    <option value=N>NIL</option>
                    <option value=S>S</option>
                    <option value=M>M</option>
                    <option value=L>L</option>
                    <option value=XL>XL</option>
                    </select></td>
                </tr>

                <tr>
                    <td>Product Image:</td>
                    <td><input type=file name=imgfile></td>
                </tr>

                <tr>
                    <td>Category: Exclusive</td>
                </tr>

                <tr>
                    <td></td>
                    <td><input type=submit name=insert value=Insert></td>
                </tr>

            </table>
            </div>

    </td>
    </tr>


    </div>



 echo("<tr><td></td>
                        <td></td>
                        <td><font style=title><b>In Stock : ".$row["qty"]."</b></br></br></br></br>
                        <b><form>Purchase Qty : <input type=number name=qty min=1 max=5></form></b></br></br>
                        </br></font></td>

                        </tr>");

                echo("<tr><td></td>
                        <td></td>
                        <td><a href=shoppingbag.php><img src=images/addToCartBtn.png width=150></a></td></tr>");
1
  • that's the html, where is the php? Commented Apr 15, 2013 at 1:46

3 Answers 3

1

your <select> requires a name attribute

Sign up to request clarification or add additional context in comments.

Comments

1

Change the following:

<select>
    <option value=N>NIL</option>
    <option value=S>S</option>
    <option value=M>M</option>
    <option value=L>L</option>
    <option value=XL>XL</option>
</select>

To:

<select name="size">
    <option value=N>NIL</option>
    <option value=S>S</option>
    <option value=M>M</option>
    <option value=L>L</option>
    <option value=XL>XL</option>
</select>

And get it using:

<?php $_POST["size"]; ?>

2 Comments

Can I check with you what about the input type number? I even tried to get by elementid but dont work
<input type="number" /> is supported only in webkit based browsers.
0

Since this is also marked under PHP, I presume you want to send these values to a PHP page?

If so, unless you are submitting the values dynamically (through script), you'll want to wrap the input and select elements in <form> opening and closing tags. Then you can set the method attribute (post,put,get,delete) and the action attribute (the path to the PHP page to process the values).

<form method="post" action="path-to/my-php-page.php">
...
</form>

HINT: The way your HTML is structured, you may want to wrap the whole of the innermost table with the form tag.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.