I've beed using this website for quite some time now but I never needed to post anything until now.
I've been a programmer in ASP.NET (C# or VB.NET) but now I'm trying to extent my knowledge to PHP as well.
Well let's get to the point.
I've created a page where the users will be able to buy come packages according to their choice and using PayPal. I've decided to use radio buttons in order to show the user the possibilities he have since all the options are stored in the database.
So I use this to create the RadioButtons:
<? while($row=mysql_fetch_assoc($result)) { ?>
<div class="PackagesInfo" style="padding: 10px 10px 10px 200px; font-size:10pt;">
<span class="PackagesInfo<?=$row['bids_number']?>"></span>
<p><input type="radio" name='package_id' value='<?= $row['id'] ?>'> <?= $row['bids_number'] ?><?php echo $MSG_40_024;?><?= print_money($row['price']) ?></input></p>
</div>
<? } ?>
Then when the user chooses the option he desires and on the onsubmit of the form I do this:
<script>
function fill_price() {
var package_choosen=0;
for (var i=0; i<document.getElementById("paypal_frm").package_id.length; i++) {
if (document.getElementById("paypal_frm").package_id[i].checked) {
package_choosen=1;
package_checked=document.getElementById("paypal_frm").package_id[i].value;
}
}
if (package_choosen!=1) {
alert("Please select a bid package!")
return false;
}
document.getElementById("custom").value +="=="+package_checked;
document.getElementById("amount").value=prices[package_checked];
}
</script>
But what is happening is that if the users chooses the option number 1 and presses the submit button and after the click he then selects another option, for some reason the second option will be used instead. This doesn't happens all the time, it's quite random actually. I have no clue what may be causing this to happen.
Thanks a lot for your time.