What is wrong in this code ? I've tried it on google chrome and the checkbox was UNCKECKED but when trying it on firefox it was checked , how does the code of a CHECKED BOX really have to look like ?
2010-2013 <input type='checkbox' name='actual' value='YES' checked ><br />
2000-2009 <input type='checkbox' name='09' value='YES' > <br />
1990-1999 <input type='checkbox' name='99' value='YES' > <br />
1980-1989 <input type='checkbox' name='89' value='YES' > <br />
1970-1979 <input type='checkbox' name='79' value='YES' > <br />
... -1969 <input type='checkbox' name='69' value='YES' > <br />
<input type='checkbox' name='actual' value='YES' checked="checked" >
Try This.
Related
Hello I will try an explain myself as clear as possible. I'm trying to add a filter products using multiple checkboxes that the user can click on that will alter the my php mysql query.
I have seen some examples of this online but they just show and hide divs. I would like to take the value of the checkboxes click and insert them in the query dynamically.
So my questions is how could I pass a value from multiple checkboxes with out using a form?
<div id="filterContentTitle">Filter Results</div>
<div id="filterContentResults">
<div id="filterContentCat">Categories</div>
<input type='checkbox' name='categories' value='1' /><label for='categories'>Dishwashers</label><br /><input type='checkbox' name='categories' value='2' /><label for='categories'>Hoods</label><br /><input type='checkbox' name='categories' value='3' /><label for='categories'>Microwaves</label><br /><input type='checkbox' name='categories' value='4' /><label for='categories'>Refrigerators</label><br /><input type='checkbox' name='categories' value='5' /><label for='categories'>Stoves & Ranges</label><br /><input type='checkbox' name='categories' value='6' /><label for='categories'>Washers & Dryers</label><br /> </div>
<hr />
<div id="filterContentResults">
<div id="filterContentCat">Brands</div>
<input type='checkbox' name='brand[]' value='GE' /><label for='brand'>GE</label><br /><input type='checkbox' name='brand[]' value='Viking' /><label for='brand'>Viking</label><br /><input type='checkbox' name='brand[]' value='Whirlpool' /><label for='brand'>Whirlpool</label><br /> </div>
<hr />
<div id="filterContentResults">
<div id="filterContentCat">Refrigerators Type</div>
<input type='checkbox' name='subCategory[]' value='French Door'><label for='subCategory'>French Door</label><br /><input type='checkbox' name='subCategory[]' value='Bult-In'><label for='subCategory'>Bult-In</label><br /><input type='checkbox' name='subCategory[]' value='Side by Side'><label for='subCategory'>Side by Side</label><br /> </div>
<hr />
<div id="filterContentResults">
<div id="filterContentCat">Refrigerators Capacity</div>
<input type='checkbox' name='capacity[]' value='20.7 cu ft'><label for='capacity'>20.7 cu ft</label><br /><input type='checkbox' name='capacity[]' value='28.6 cu ft'><label for='capacity'>28.6 cu ft</label><br /><input type='checkbox' name='capacity[]' value='20.4 cu ft'><label for='capacity'>20.4 cu ft</label><br /><input type='checkbox' name='capacity[]' value='24.6 Cu. Ft.'><label for='capacity'>24.6 Cu. Ft.</label><br /><input type='checkbox' name='capacity[]' value='25 cu. ft.'><label for='capacity'>25 cu. ft.</label><br /><input type='checkbox' name='capacity[]' value='22.0 Cu. Ft.'><label for='capacity'>22.0 Cu. Ft.</label><br /> </div>
<hr />
<div id="filterContentResults">
<div id="filterContentCat">Condition</div>
<input type='checkbox' name='condition[]' value='New'><label for='condition'>New</label><br /> </div>
<hr />
<div id="filterContentResults">
<div id="filterContentCat">Color</div>
<input type='checkbox' name='color[]' value='Stainless Steel'><label for='color'>Stainless Steel</label><br /><input type='checkbox' name='color[]' value='Black'><label for='color'>Black</label><br /><input type='checkbox' name='color[]' value='Biscuit'><label for='color'>Biscuit</label><br /> </div>
What you can do is bind into the jQuery change event on the input.
When the inputs are changed, you can then update the query that is being sent (presumably with Ajax) to the PHP script
$("input").change(function() {
updateProductList($(this).attr("id"), $(this).prop("checked"));
});
function updateProductList(field, state) {
// Do Work
$.ajax({
source: "my-url.php?" + field + "=" + state
});
}
Note: the example is simplified, but hopefully you get the idea.
I seem to have a problem with an email form I am making.
the form worked correctly until I added some extra parts to it. however, even when I comment my changes, it won't work.
I thought the problem might be due to some syntax error, but It doesn't seem to be so.
I do not get any error message
below is my code:
<?php
if(isset($_REQUEST['email'])) {
$num=$_REQUEST['num'];
$desc=$_REQUEST['desc'];
$subject="einak";
$nomr=$_REQUEST['nomr'];
$sphr=$_REQUEST['sphr'];
$cylr=$_REQUEST['cylr'];
$angr=$_REQUEST['angr'];
$addr=$_REQUEST['addr'];
$diar=$_REQUEST['diar'];
$noml=$_REQUEST['noml'];
$sphl=$_REQUEST['sphl'];
$cyll=$_REQUEST['cyll'];
$angl=$_REQUEST['angl'];
$addl=$_REQUEST['addl'];
$dial=$_REQUEST['dial'];
$type=$_REQUEST['type'];
$matter=$_REQUEST['matter'];
$color=$_REQUEST['color'];
$message=$num."<br />".$nomr."<br/>".$sphr."<br/>".$cylr."<br/>".$angr."<br />".$addr."<br />".$diar."<br />"."<br />".$noml."<br/>".$sphl."<br/>".$cyll."<br/>".$angl."<br />".$addl."<br />".$dial."<br />".$desc."<br />".$type."<br />".$matter."<br />".$color."<br />";
$email='info#toosoptic.ir';
$headers='MIME-Version: 1.0'."\r\n";
$headers.='Content-type: text/html; charset=iso-8859-1'."\r\n";
mail("mail#example.com",$subject,$message,$headers);
echo "ارسال شما موفقیت آمیز بود";
} else {
echo "<form method='post'>
<input name='num' id='num' type='text' /> <br />
<input type='text' name='nomr' id='nomr' > <br />
<input type='text' name='sphr' id='sphr'> <br />
<input type='text' name='cylr' id='cylr' > <br />
<input type='text' name='angr' id='angr' > <br />
<input type='text' name='addr' id='addr' > <br />
<input type='text' name='diar' id='diar' > <br />
<input type='text' name='noml' id='noml' > <br />
<input type='text' name='sphl' id='sphl'> <br />
<input type='text' name='cyll' id='cyll' > <br />
<input type='text' name='angl' id='angl' > <br />
<input type='text' name='addl' id='addl' > <br />
<input type='text' name='dial' id='dial' > <br />
<textarea id='desc' name='desc'> </textarea>
<input name='type' type='radio' value='bifocal' id='type1' />
<input name='type' type='radio' value='progres' id='type2' />
<input name='type' type='radio' value='single' id='type3' />
<input name='type' type='radio' value='decen' id='type4' />
<input name='matter' type='radio' value='glass' id='mat1' />
<input name='matter' type='radio' value='plastic' id='mat2' />
<input name='color' type='radio' value='single' id='col1' />
<input name='color' type='radio' value='decen' id='col2' />
<input type='submit' id='sb' value='ارسال اطلاعات' />
<input type='text' name='name' id='name' > <br />
<input type='add' name='address' id='address' > <br />
</form >
<p id='confirmation'></p>
<input type='submit' id='vis' onClick='vis(); return false;' value='تایید اطلاعات'/>";
}
?>
You have not define the name in the submit button here:
<input type='submit' id='sb' value='ارسال اطلاعات' />
Replace above code with the below code:
<input type='submit' id='sb' name='email' value='ارسال اطلاعات' />
You are checking the code if(isset($_REQUEST['email'])) and there is no email field the form as I see.
Basically this check is used for verifying that form have submitted or not(as generally other do). So you need to add the name='email' in the submit button attribute to execute the if condition code..
You're setting a mime header but you're not setting any mime encoding, that might be one issue ;-)
Try using a dedicated package such as PEAR/Mail (and PEAR/Mail/Mime) or phpMailer.
Page contains product details and rate them.
Rating is 5 stars that is works with ajax.
I want to cache these pages in server side but how can i cache product details without rating.
<div class='product-container' >
<div class='product-container-right' >
<h3>product-name</h3><br/>
<p>some detail about product</p>
</div>
<div class='vote-request'>rate this product:</div><br/>
<div id='productvote-20' class='product-vote' >
<input type='checkbox' name='vote' value='1' />
<input type='checkbox' name='vote' value='2' />
<input type='checkbox' name='vote' value='3' />
<input type='checkbox' name='vote' value='4' />
<input type='checkbox' name='vote' value='5' />
</div>
</div>
I want to cache div class='product-container-right' in server side.
how every time page (div class='product-container-right') is loaded from cache read div id='productvote-20' class='product-vote' by javascript( or jquery).
you need to add AJAX request that will run once on document-ready to get rating from PHP page and update the rating
$(document).ready( function(){
$('#productvote-20').load('Rating.php?productId=1');
})
And in that PHP file, you need to output this.. but don't cache that page
<input type='checkbox' name='vote' value='1' />
<input type='checkbox' name='vote' value='2' />
<input type='checkbox' name='vote' value='3' />
<input type='checkbox' name='vote' value='4' />
<input type='checkbox' name='vote' value='5' />
Hi guys and sorry for my english,
I try to make a simple UPDATE through selected radio buttons, but it's not working. I have a 3 <input type='radio'> buttons in while loop and every button should do something else which I want to filtered.
$result=mysql_query("SELECT id FROM table WHERE state=0");
while ($record=mysql_fetch_array($result)):
<form method='post' action=''>
<input type='radio' name='state' value='1' /> 1
<input type='radio' name='state' value='2' /> 2
<input type='radio' name='state' value='3' /> 3
<input type='submit' value='Send' />
</form>
endwhile;
If I choose one of the three button and click on "Send", then one row (based on ID) should be UPDATE a MySQL db:
mysql_query ("UPDATE table SET state=(selected radio button number 1-3) WHERE id=$record[id]");
But, the script it must be out of the while loop and if I make it this way, it's not working because the script can't recognize which ID was chosen.
If I make it like this:
$result=mysql_query("SELECT id FROM table WHERE state=0");
while ($record=mysql_fetch_array($result)):
<form method='post' action=''>
<input type='radio' name='state' value='$record[id]' /> 1
<input type='radio' name='state' value='$record[id]' /> 2
<input type='radio' name='state' value='$record[id]' /> 3
<input type='submit' value='Send' />
</form>
endwhile;
then ID is recognize by script, but I don't know, how can I filtered which number (1, 2 or 3) is sending to UPDATE query for "state" column. It's a big dilemma for me and I can't figure out. I need to recognized ID and filter the chosen number (1-3). Can you help me out ?
There is two options.
First:
$result=mysql_query("SELECT id FROM table WHERE state=0");
while ($record=mysql_fetch_array($result)):
<form method='post' action=''>
<input type='hidden' name='recordId' value='$record[id]' />
<input type='radio' name='state' value='1' />
<input type='radio' name='state' value='2' />
<input type='radio' name='state' value='3' />
<input type='submit' value='Send' />
</form>
endwhile;
and
$recordId = (int)$_POST['recordId'];
$state = (int)$_POST['state'];
mysql_query ("UPDATE table SET state=$state WHERE id=$recordId");
Second:
$result=mysql_query("SELECT id FROM table WHERE state=0");
<form method='post' action=''>
while ($record=mysql_fetch_array($result)):
<input type='radio' name='state[$record[id]]' value='1' />
<input type='radio' name='state[$record[id]]' value='2' />
<input type='radio' name='state[$record[id]]' value='3' />
endwhile;
<input type='submit' value='Send' />
</form>
and
foreach($_POST['state'] as $key => $val) {
$recordId = (int)$key;
$state = (int)$val;
mysql_query ("UPDATE table SET state=$state WHERE id=$recordId");
}
(note that the code above is probably not syntactically correct, and given as an illustration to the idea)
Also, mixing up code and data is a bad practice; consider using prepared statements instead.
I am trying to submit the following paypal form through a hosted-payment system. however, it does not seem to be passing through any of the variables apart from the price.
Can anyone see where I am going wrong:
<form action='https://securepayments.paypal.com/cgi-bin/acquiringweb' method='post' target='hss_iframe' id='PayPalForm' name='PayPalForm'>
<input type='hidden' name='cmd' value='_hosted-payment' />
<input type='hidden' name='charset' value='utf-8' />
<input type='hidden' name='currency_code' value='GBP' />
<input type='hidden' name='business' value='seller#email.com' />
<input type='hidden' name='paymentaction' value='sale' />
<input type='hidden' name='template' value='TemplateD' />
<input type='hidden' name='return' value='http://yoursite.com/groupon-success.php' />
<input type='hidden' name='notify_url' value='http://yoursite.com/paypal-groupon- ipn.php' />
<input type='hidden' name='item_name' value='Item name' />
<input type='hidden' name='item_number' value='4' />
<input type='hidden' name='subtotal' value='0.01' />
<input type='hidden' name='custom' value='41' />
<input type='hidden' name='address_override' value='true' />
<input type='hidden' name='first_name' value='Jack' />
<input type='hidden' name='last_name' value='Jones' />
<input type='hidden' name='address1' value='address1' />
<input type='hidden' name='city' value='Manchester' />
<input type='hidden' name='zip' value='M20 1AA' />
<input type='hidden' name='country' value='UK' />
<input type='hidden' name='billing_first_name' value='Jack' />
<input type='hidden' name='billing_last_name' value='Jones' />
<input type='hidden' name='billing_address1' value='address1' />
<input type='hidden' name='billing_city' value='Manchester' />
<input type='hidden' name='billing_zip' value='M20 1AA' />
<input type='hidden' name='billing_country' value='UK' />
</form>
it is then been passed to an iframe which seems to work fine using:
<iframe width="100%" scrolling="no" height="580px" frameborder="no" name="hss_iframe" style="float:right;"></iframe>
<script type="text/javascript">
$(function(){
$("#PayPalForm").submit();
});
</script>
Can anyone help with why this data does not seem to pass anything through
--------------- EDIT
Changed cmd to _xclick and passes through fine, so obviously an issue with _hosted-payment
Can anyone give any ideas
If by "however, it does not seem to be passing through any of the variables", you mean it doesn't display the item name / item number: that's correct. Website Payments Pro Hosted Solution doesn't currently support item details. You should remove these parameters as they're not in use for this product.
In addition, the billing/shipping address will be used, but you won't be able to modify them if you're using templateD.