Jump to content

getting span id in php?


techker

Recommended Posts

Hey guys i got an invoice form that has the totals in a span id

 

 

        SUB ::<span id="small_total"></span><br />
        TPS :: <span id="tps"></span><br />
        TVQ :: <span id="tvq"></span><br />
        GRAND TOTAL :: <span id="grand_total"></span><br />
 
 

 

so its part of a form,when i submit to add to databse i can't seem to figure out how to get the values of the id?

 

i have tried a few things with no success..

 

exp

in the add.php page(form submit action)

$GT = "<script language='javascript'>document.getElementById(grand_total);</script>";

 

Link to comment
Share on other sites

i got an invoice form that has the totals in a span id

 

 

things you display on a web page are just for display purposes. if you need the total on the server, you should calculate it from the original source data values so that someone cannot alter the DOM in the browser and submit any value they want to your server-side code.

Link to comment
Share on other sites

im going to post my code.it's in a for..

 

 

<form id="submit_form" action="ADD.php"  method="post"  >
         SUB ::<span id="small_total"></span><br />
        TPS :: <span id="tps"></span><br />
        TVQ :: <span id="tvq"></span><br />
        GRAND TOTAL :: <span id="grand_total"></span><br />
         <div class="action_bar">
         
          
       <input type="submit" name="submit" /> 
          </div>
      
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="42%">PRODUCT</td>
    <td width="11%">QTY</td>
    <td width="10%">PRICE</td>
    <td width="37%">TOTAL</td>
  </tr>
  <tr>
    <td><p class="large"><input type="text" id="street" class="item_title"  name="obj1"> </p></td>
    <td> <p class="small">  <input type="text" id="number"  value="0" class="item_quantity" name="qty1"></p> </td>
    <td><p class="small">  <input type="text" value="0"class="item_price"  name="price1"></p> </td>
    <td><span class="item_small_total"></span></td>
  </tr>
  <tr>
    <td><p class="large"><input type="text" id="street" class="item_title"  name="obj2">  </p></td>
    <td> <p class="small">  <input type="text" id="number"  value="0" class="item_quantity" name="qty2"></p> </td>
    <td><p class="small">  <input type="text" value="0"class="item_price"  name="price2"></p></td>
    <td><span class="item_small_total"></span></td>
  </tr>
  <tr>
    <td><p class="large"><input type="text" id="street" class="item_title"  name="obj3"> </p></td>
    <td> <p class="small">  <input type="text" id="number"  value="0" class="item_quantity" name="qty3"> </p></td>
    <td><p class="small">  <input type="text" value="0"class="item_price"  name="price3"></p> </td>
    <td><span class="item_small_total"></span></td>
  </tr>
  <tr>
    <td><p class="large"> <input type="text" id="street" class="item_title"  name="obj4">  </p></td>
    <td> <p class="small">  <input type="text" id="number"  value="0" class="item_quantity" name="qty4"> </p></td>
    <td><p class="small">  <input type="text" value="0"class="item_price"  name="price4"></p> </td>
    <td><span class="item_small_total"></span></td>
  </tr>
  <tr>
    <td><p class="large"><input type="text" id="street" class="item_title"  name="obj5"> </p></td>
    <td> <p class="small">  <input type="text" id="number"  value="0" class="item_quantity" name="qty5"></p> </td>
    <td><p class="small">  <input type="text" value="0"class="item_price"  name="price5"></p> </td>
    <td><span class="item_small_total"></span></td>
  </tr>
  <tr>
   <td><p class="large"><input type="text" id="street" class="item_title"  name="obj6"> </p></td>
    <td> <p class="small">  <input type="text" id="number"  value="0" class="item_quantity" name="qty6"></p> </td>
    <td><p class="small">  <input type="text" value="0"class="item_price"  name="price6"></p> </td>
    <td><span class="item_small_total"></span></td>
  </tr>
  <tr>
   <td><p class="large"><input type="text" id="street" class="item_title"  name="obj7"> </p></td>
    <td> <p class="small">  <input type="text" id="number"  value="0" class="item_quantity" name="qty7"></p> </td>
    <td><p class="small">  <input type="text" value="0"class="item_price"  name="price7"></p> </td>
    <td><span class="item_small_total"></span></td>
  </tr>
      
          </table>
           
</form>
Link to comment
Share on other sites

If you want it accessible through a form and still seen in your span, you'll have to add it to a hidden input.

 

 

<input type="hidden" name="grand_total" value="grand_total_amount_here">

 

Either way it will still be editable by a user.  The only way to do it securely would be to follow mac_gyver's advice.

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.