Scooby08 Posted August 9, 2008 Share Posted August 9, 2008 Im having a problem figuring this one out, and I am out of ideas.. I have this code: <table> <tr><th>Wedding Packages</th><th>Choose One</th><th>Unit Price</th><th>Cost</th></tr> <?php $query_wp = "SELECT item_id, item_description, item_price FROM dw_items WHERE item_category = 'wedding_packages'"; $result_wp = mysql_query($query_wp) or die(mysql_error()); while($row_wp = mysql_fetch_array($result_wp)) { ?> <tr> <td><?=$row_wp['item_description'];?></td> <td><input type="radio" name="item_id_wp" value="<?=$row_wd['item_id'];?>" id="qty_item_1" /></td> <td id="price_item_1">15.99</td> <td id="total_item_1"></td> </tr> <?php } ?> </table> It pulls the data from the database and displays multiple rows of radio buttons.. Works out great for me.. Here is the problem.. I need to figure out a way to get the value of each radio input to equal 1 if clicked and 0 if unclicked.. But also I am using the value to send which item was checked to the database, so as right now the value is whatever it pulls from the database.. The reason I need the value to equal 1 when checked is because each input has a dollar amt value and I am using the jquery calculation plugin which relies on each value to calculate the total.. I hope somebody can understand this.. I have tried adding this to the end of each input and it almost does what is needed.. onclick="this.value = 1;" onblur="this.value = <?=$row_wp['item_id_wp'];?>;" The value is set to 1 for the calculation, and then the onblur is the value I wish to send to the database.. Problem is when the onblur takes effect the calculation is thrown off with the original value and the total is then incorrect again.. Guess Im looking for the ultimate answer here.. Quote Link to comment Share on other sites More sharing options...
Attila Posted August 9, 2008 Share Posted August 9, 2008 I beleive your problem is here; <td><input type="radio" name="item_id_wp" value="<?=$row_wd['item_id'];?>" id="qty_item_1" /></td> It should be <td><input type="radio" name="item_id_wp" value="<? $row_wd['item_id']; ?>" id="qty_item_1" /></td> Basickly you have an extra = sign you do not need. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted August 9, 2008 Share Posted August 9, 2008 The = is for short tag echo, which shouldn't really be used. Try using full PHP tags: <?php echo $row_wd['item_id']; ?> Quote Link to comment Share on other sites More sharing options...
Scooby08 Posted August 9, 2008 Author Share Posted August 9, 2008 Hey guys.. Thanks for the reply!! I see what you are saying, but I need a value in there.. The = sign is just used to echo the value and it works just fine.. The problem is beyond that.. What you see there works just fine for entering data into the database.. Its the calculation that is getting screwed up with this.. Here is a quick example of what's going on here.. <input type="radio" name="item_id_wp" value="1" id="qty_item_1" /> <input type="radio" name="item_id_wp" value="2" id="qty_item_1" /> <input type="radio" name="item_id_wp" value="3" id="qty_item_1" /> Now there the value is just called from the database, but the jquery calculation plugin I am using uses that value to multiply the value... So those lines would be like so: <input type="radio" name="item_id_wp" value="1" id="qty_item_1" /> (1 * $10.00) = $10.00 <input type="radio" name="item_id_wp" value="2" id="qty_item_1" /> (2 * $10.00) = $20.00 <input type="radio" name="item_id_wp" value="3" id="qty_item_1" /> (3 * $10.00) = $30.00 when I need them to be like so: <input type="radio" name="item_id_wp" value="1" id="qty_item_1" /> (1 * $10.00) = $10.00 <input type="radio" name="item_id_wp" value="2" id="qty_item_1" /> (1 * $10.00) = $10.00 <input type="radio" name="item_id_wp" value="3" id="qty_item_1" /> (1 * $10.00) = $10.00 but still send the original called values to the database with their choice of which radio button was checked.. Im sorry it's so confusing, but I have no where else to go for help.. Thank you.. Can I post example links on here without problem? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.