javascript - GET parameter not passing through -


i'm having weird error while trying pass get variables. on product page have multiple sizes same product, each size has own form 2 variables, product id (product_id) , quantity (qty), sent page (add.php) added cart.

my problem qty passed no problem product_id not go through, used burp suite check data sent between server , client , when click on submit button product_id not attached url (as can see below)

get /newsite/add.php?qty=1 http/1.1

here code use

$selectquery = "select * products product_master_id = $masterid order length(product_quantity_description), product_quantity_description"; $selectresult = mysql_query($selectquery); $i = 0; while($selectrow = mysql_fetch_array($selectresult)) {     echo '<form action="add.php?product_id='.$selectrow['product_id'].'&qty=<script>document.getelementbyid(\'qty'.$i.'\').value</script>" class="form form-inline clearfix">     <span class="tag" id="desc">'.$selectrow['product_name'].'</span>                                        <span class="tag" id="qtydesc">$'.$selectrow['product_quantity_description'].'</span>     <span class="tag" id="oldprice">$'.number_format ($selectrow['old_price'], 2).'</span>     <span class="tag" id="averageprice">$'.number_format ($selectrow['average_price'], 2).'</span>     <span class="tag" id="price">$'.number_format ($selectrow['product_price'], 2).'</span>     &nbsp;     <div class="numbered">         <input type="text" name="qty" id="qty'.$i.'" value="1" class="tiny-size" />         <span class="clickable add-one icon-plus-sign-alt"></span>         <span class="clickable remove-one icon-minus-sign-alt"></span>     </div>';     if($selectrow['special'] == 1 && $selectrow['product_oos'] == 0)         echo '<span class="stock">             <span class="btn btn-warning" id="stock">ask availability</span>             </span>';     if($selectrow['product_oos'] == 1)         echo '<span class="btn btn-danger pull-right">out of stock</span>';     else         echo '<button class="btn btn-success pull-right">add &nbsp; <i class="icon-shopping-cart"></i></button>';     echo '</form>';     $i++; } 

this can see looking @ source code of loaded page

<form action="add.php?product_id=559&amp;qty=&lt;script&gt;document.getelementbyid('qty0').value&lt;/script&gt;" class="form form-inline clearfix"> 

i didn't understand why qty gets appended url not product_id.

in situation have passed variables in hidden fields. not make simple things complex.

<input type="hidden" name="product_id" value="$selectrow['product_id']" /> <input type="hidden" name="qty" value="document.getelementbyid(\'qty'.$i.'\').value" /> 

and make

<input type="text" name="qty"  id="qty'.$i.'" value="1" class="tiny-size" /> 

to

<input type="text"  id="qty'.$i.'" value="1" class="tiny-size" /> 

now code looks like.

$selectquery = "select * products product_master_id = $masterid order     length(product_quantity_description), product_quantity_description"; $selectresult = mysql_query($selectquery); $i = 0; while($selectrow = mysql_fetch_array($selectresult)) { echo '<form action="add.php" class="form form-inline clearfix"> <span class="tag" id="desc">'.$selectrow['product_name'].'</span>                                    <span class="tag" id="qtydesc">$'.$selectrow['product_quantity_description'].'</span> <span class="tag" id="oldprice">$'.number_format ($selectrow['old_price'], 2).'</span> <span class="tag" id="averageprice">$'.number_format ($selectrow['average_price'], 2).'</span> <span class="tag" id="price">$'.number_format ($selectrow['product_price'], 2).'</span> &nbsp; <div class="numbered"> <input type="hidden" name="product_id" value="$selectrow['product_id']" /> <input type="hidden" name="qty" value="document.getelementbyid(\'qty'.$i.'\').value" />        <input type="text"  id="qty'.$i.'" value="1" class="tiny-size" />     <span class="clickable add-one icon-plus-sign-alt"></span>     <span class="clickable remove-one icon-minus-sign-alt"></span> </div>'; if($selectrow['special'] == 1 && $selectrow['product_oos'] == 0)     echo '<span class="stock">         <span class="btn btn-warning" id="stock">ask availability</span>         </span>'; if($selectrow['product_oos'] == 1)     echo '<span class="btn btn-danger pull-right">out of stock</span>'; else     echo '<button class="btn btn-success pull-right">add &nbsp; <i class="icon-shopping-cart"></i></button>'; echo '</form>'; $i++; 

}


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -