PDA

View Full Version : onclick checkbox form submission



marynorn
04-02-2008, 12:06 PM
I have a little checkbox where people can opt out of receiving a paper version of our newsletter. Using a submit button seems like overkill for one tiny little checkbox. Is there a javascript value that would POST onclick?


<?php
if ($tenant->isLoggedIn())
{
$tenantDetails = $tenant->getTenantDetails();
?><?php } ?>

<form id="news_out" name="news_out" method="post" action="news_ty.php">

<p>
<input type="hidden" name="name" id="name" value="<?php echo $tenantDetails['tenantName'] ?>" />
<input name="email" type="hidden" value="<?php echo $_SESSION['tenantEmail'] ?>" />
</p>

<p>Don't send me a paper copy, I want my Newsletter e-mailed to me.
<input <?php if (!$tenant->isLoggedIn()) {echo 'disabled';} ?> type="checkbox" name="newsletter" id="newsletter" />
</p>
</form>

thetestingsite
04-03-2008, 12:11 AM
You could try the following (not tested):



<?php
if ($tenant->isLoggedIn())
{
$tenantDetails = $tenant->getTenantDetails();
?><?php } ?>

<form id="news_out" name="news_out" method="post" action="news_ty.php">

<p>
<input type="hidden" name="name" id="name" value="<?php echo $tenantDetails['tenantName'] ?>" />
<input name="email" type="hidden" value="<?php echo $_SESSION['tenantEmail'] ?>" />
</p>

<p>Don't send me a paper copy, I want my Newsletter e-mailed to me.
<input <?php if (!$tenant->isLoggedIn()) {echo 'disabled';} ?> type="checkbox" name="newsletter" id="newsletter" onclick="this.form.submit();" />
</p>
</form>


Hope this helps.