Php recordset outputting last value from while loop
Hi all,
I have an issue with a site I am making which lists radio buttons which are a set of donation options (some with predefined prices some with user dependant).
I used jQuery to populate a textbox with the value of the radio buttons so the person does not need to enter a price they want to donate.
The issue I am having is that I want the page to carry across the fund_id (which is the primary key) to the next page.
Currently the do / while loop goes through all of the recordset and passes across the last record's fund_id.
Please see my code below:
Code:
$(function () {
$('input.radioButton').click(function () {
var checkedradio = $('[name="fund"]:radio:checked').val();
$('#totalPrice').val(checkedradio);
});
});
And
Code:
<form action="donate2.php" method="post" name="donateFormScript">
<h1>Select Fund</h1>
<h3>General</h3>
<?php do { ?>
<label><input class="radioButton" type="radio" name="fund" value="<?php echo $row_cat_general['fund_price']; ?>" id="<?php echo $row_cat_general['fund_name']; ?>" /><?php echo $row_cat_general['fund_name']; ?> <?php if ($row_cat_general['fund_price']!="") { ?>- £<?php echo $row_cat_general['fund_price']; ?><?php } else {?> <?php };?></label>
<br />
<?php } while ($row_cat_general = mysql_fetch_assoc($cat_general)); ?>
<h3>Sponsorship</h3>
<?php do { ?>
<label><input class="radioButton" type="radio" name="fund" value="<?php echo $row_cat_sponsorship['fund_price']; ?>" /><?php echo $row_cat_sponsorship['fund_name']; ?> <?php if ($row_cat_sponsorship['fund_price']!="") { ?>- £<?php echo $row_cat_sponsorship['fund_price']; ?><?php } else {?> <?php };?></label>
<br />
<?php } while ($row_cat_sponsorship = mysql_fetch_assoc($cat_sponsorship)); ?>
<h3>Seasonal</h3>
<?php do { ?>
<label><input class="radioButton" type="radio" name="fund" value="<?php echo $row_cat_seasonal['fund_price']; ?>" /><?php echo $row_cat_seasonal['fund_name']; ?> <?php if ($row_cat_seasonal['fund_price']!="") { ?>- £<?php echo $row_cat_seasonal['fund_price']; ?><?php } else {?> <?php };?></label>
<br />
<?php } while ($row_cat_seasonal = mysql_fetch_assoc($cat_seasonal)); ?>
<br />
<span id="sprytextfield1">
<label>Enter Amount:
<input name="total" type="text" id="totalPrice" />
</label>
<span class="textfieldRequiredMsg">A donation amount is required.</span></span><br />
<input name="fund_id" type="hidden" value="<?php echo $row_cat_general['fund_id']; ?>" id="fund_id" />
<input name="button" type="submit" value="Select" />
</form>
I hope this doesnt look weird, once I have post this.
Is there a way I can populate "totalPrice" input box AND have "fund_id" hidden field populated with the fund_id of the selected radio button?
Thanks for your help.
From the top of my head
Pass the fund_id to a hidden input on the form for each radio box. Then get and set the value together with the jQuery function for the radio box.
I'm not sure how to do that with jQuery.
I have no experience with jQuery.
Hi,
I tried to make your suggestion work but it still outputs the last record in the table.
Thanks
Does anyone know of any good donation scripts that have multiple donatable causes?
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks