I have an issue where my trigger event is not happening in Firefox and Safari but works in Chrome.
The trigger event is called here:
<script>
function capture() {
//console.log("function is running");
jQuery('#square').html2canvas({
onrendered: function (canvas) {
var url;
url = canvas.toDataURL("image/png");
jQuery('#img_val').val(canvas.toDataURL("image/png"));
jQuery("#buttonSubmit").trigger( "click" );
}
});
}
</script>
It's triggered from a button in a form:
<form name="addpro" style="float:right;" method="post">
<input id="textInput" name="textInput" type="hidden" value="Vælg tekst, farve mv. under skiltet">
<input id="text2Input" name="text2Input" type="hidden" value="">
<input id="størrelseInput" name="størrelseInput" type="hidden" value="155x60">
<input id="formInput" name="formInput" type="hidden" value="Firkant">
<input id="farveInput" name="farveInput" type="hidden" value="Sort">
<input id="typeInput" name="typeInput" type="hidden" value="Messing Standard">
<input id="fastgøringInput" name="fastgøringInput" type="hidden" value="Skruer">
<input id="fontInput" name="fontInput" type="hidden" value="Arial">
<input id="fontSizeLine1Input" name="fontSizeLine1Input" type="hidden" value="6">
<input id="fontSizeLine2Input" name="fontSizeLine2Input" type="hidden" value="6">
<input id="priceInput" name="priceInput" type="hidden" value="470">
<input type="hidden" name="img_val" id="img_val" value="tape.png" />
<button onclick="capture();" class="buttonSign" value="Læg i kurven" />Læg i kurven</button>
<input class="buttonSign hidden" id="buttonSubmit" type="submit" name="addcustomcarts" value="Læg i kurven" />
</form>
As you can see I want to run the function capture(); before submitting the form! This works in chrome but not in firefox and safari - what's wrong here?
I was initially unable to replicate the issue via JSFiddle. I had to adjust a few things. With the following HTML:
<div id="square">
</div>
<form name="addpro" style="float:right;" method="post">
<input id="textInput" name="textInput" type="hidden" value="Vælg tekst, farve mv. under skiltet" />
<input id="text2Input" name="text2Input" type="hidden" value="" />
<input id="størrelseInput" name="størrelseInput" type="hidden" value="155x60" />
<input id="formInput" name="formInput" type="hidden" value="Firkant" />
<input id="farveInput" name="farveInput" type="hidden" value="Sort" />
<input id="typeInput" name="typeInput" type="hidden" value="Messing Standard" />
<input id="fastgøringInput" name="fastgøringInput" type="hidden" value="Skruer" />
<input id="fontInput" name="fontInput" type="hidden" value="Arial" />
<input id="fontSizeLine1Input" name="fontSizeLine1Input" type="hidden" value="6" />
<input id="fontSizeLine2Input" name="fontSizeLine2Input" type="hidden" value="6" />
<input id="priceInput" name="priceInput" type="hidden" value="470" />
<input type="hidden" name="img_val" id="img_val" value="tape.png" />
<button id="buttonCart" class="buttonSign" value="Læg i kurven" />Læg i kurven</button>
<input class="buttonSign hidden" id="buttonSubmit" type="submit" name="addcustomcarts" value="Læg i kurven" />
</form>
I could execute the following JQuery:
jQuery(document).ready(function(){
jQuery("form[name='addpro']").submit(function(e){
e.preventDefault();
console.log("Form Submitted");
});
jQuery("#buttonCart").click(function(){
html2canvas(jQuery("#square"),{
onrendered: function(canvas){
var imgVal = canvas.toDataURL("image/png");
jQuery("#img_val").val(imgVal);
console.log("Image rendered: " + imgVal);
},
logging: true
});
jQuery("#buttonSubmit").click();
});
});
My jsfiddle: http://jsfiddle.net/Twisty/673q4dmm/10/
This includes the html2canvas v0.4.0 and does seem to work, yet submits the form twice. This might be an issue with the way this plugin works. I have yet to found a work around.
Related
I'm testing cardstream payment gateway with sandbox details. I tried to change redirectURL. when I change it I got below error. if I keep it with "https://www.merchant.com/payment/" , it is working.
<html>
<head>
<script src="https://gateway.cardstream.com/sdk/web/v1/js/hostedforms.min.js"></script>
</head>
<body>
<form name="payment-form" method="post" action="https://gateway.cardstream.com/hosted/" data-hostedform-modal>
<input type="hidden" name="merchantID" value="100001" />
<input type="hidden" name="action" value="SALE" />
<input type="hidden" name="type" value="1" />
<input type="hidden" name="currencyCode" value="826" />
<input type="hidden" name="countryCode" value="826" />
<input type="hidden" name="amount" value="1001" />
<input type="hidden" name="orderRef" value="Test purchase" />
<input type="hidden" name="redirectURL" value="https://www.merchant.com/payment/" />
<input type="hidden" name="signature" value="07599ef4cdb2e26cb2bf34a9c65190a7ce82494bc1df144c3bb0d20ee2655d8278dc663b2b0421ef12b8f081e821151bb4c644277c5d65b5523a96539b53b5aa" />
<input type="submit" value="Pay Now">
</form>
<script>
var form = new window.hostedForms.classes.Form(document.forms[0]);
</script>
</body>
</html>
I have to submit this form to a payment processing gateway on my PHP page. All the credit card payment information will be taken on the next screen but the gateway needs the "HostedKey" and "Gateway_ID" need to be invisible from public code view as well.
<form action="nextpage.php" method ="POST" target="_blank">
Patient Account Number:
<input type="text" name="CustRefID" id="CustRefID">
<input type="hidden" name="HostedKey" id="HostedKey" value="ZZZZZZ" />
<input type="hidden" name="Gateway_ID" id="Gateway_ID" value="XXXXXX" />
<input type="hidden" name="IndustryCode" id="IndustryCode" value="2" />
<input type="hidden" name="Amount" id="Amount" value="" />
<input type="hidden" name="RecurringType" id="RecurringType" value="N" />
<input type="hidden" name="RecurringAmount" id="RecurringAmount" value="" />
<input type="hidden" name="CURL" id="CURL" value="back to my site" />
<input type="hidden" name="AVSRequired" id="AVSRequired" value="Y"/>
<input type="hidden" name="CVV2Required" id="CVV2Required"value="Y"/>
<input type="hidden" name="EmailRequired" id="EmailRequired" value="Y"/>
<input type="hidden" name="PostRspMsg" id="PostRspMsg" value="Y"/>
<input type="hidden" name="SECCode" id="SECCode" value="1" />
<input type="hidden" name="Descriptor" id="Descriptor" value="Online" />
<input type="Submit" name="Submit" id="Submit" value="Pay Online Now" />
</form>
I tried something like this. It hid the Key and ID but the form did not pass on the hidden session variables.
<strong>Patient Account Number: </strong>
<form action="nextpage.php" method"post">
<input type="text" name="CustRefID"/>
<input type="hidden" name="HostedKey" id="HostedKey" value="" />
<input type="hidden" name="Gateway_ID" value="<?php ($Gateway_ID); ?>" />
<input type="hidden" name="HostedKey" value="<?php ($HostedKey); ?>" />
<input type="submit" name="Submit" value="Submit" />
</form>
<?php
if (isset($_POST['Submit']))
{ $_session['CustRefID'] = $_POST['CustRefID'];}
{ $_session['HostedKey'] = $_POST['xxxxxx'];}
{ $_session['Gateway_ID'] = "zzzzzz";}
?>
<strong><? echo $_session['CustRefID'];?></strong>
Any help would be great. My programmer is out sick...
You have repetition in your HTML. Change it to this:
<input type="hidden" name="Gateway_ID" value="<?php ($Gateway_ID); ?>" />
<input type="hidden" name="HostedKey" value="<?php ($HostedKey); ?>" />
2. You didn't specify what POST info should go in the SESSION. Change it to this:
{
$_SESSION['CustRefID'] = $_POST['CustRefID'];
$_SESSION['HostedKey'] = $_POST['HostedKey'];
$_SESSION['Gateway_ID'] = $_POST['HostedKey'];
}
<button type="button" >total?</button>
<?php $abc= '<div id="output"></div>';
echo $abc;?>
<form class="paypal" action="payments.php" method="post" id="paypal_form" target="_blank" runat="server">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="lc" value="UK" />
<input type="hidden" name="currency_code" value="GBP" />
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynow_LG.gif:NonHostedGuest" />
<input type="hidden" name="first_name" value="Customer's First Name" />
<input type="hidden" name="last_name" value="Customer's Last Name" />
<input type="hidden" name="payer_email" value="customer#example.com" />
<input type="hidden" name="item_number" value="123456" / >
<input type="submit" value="Submit Payment"/>
</form>
<script type='text/javascript'>
$('button').click(function() {
var total = $(':checkbox:checked.case').get().reduce(function(total, checkbox) {
return total + +checkbox.value;
}, 0);
$("#output").html(total);
});
</script>
The code contains a button that grabs the total sum from the checked answers. I need to pass this value to the payment gateway.
Thanks in advance....
You need another input for amount in your form
<input type="hidden" name="amount" value="">
Then, instead of $('button').click register form submit event like
$(function(){
$('#paypal_form').on('submit', function(e){
var total = 'get total here';
if(!total)
{
e.preventDefault();
return false;
}
$(this).find("[name='amount']").val(total);
return true;
});
});
I use the farbtastic color picker, I included all files for this, but how can I call this color picker when I double click?
More info:
That's my placeholder in my .tpl file. and I call it as follow.
// color picker selecteren.
$(function(){
$("#color").dbclick(function(){
$('#colorpicker').farbtastic('#color');
});
});
<!-- new color form -->
<form action="controller.php" method="post" class="popupform" id="form_changecolor">
<div id="colorpicker"></div>
<table>
<tr><th>huidige:</th><th>nieuwe:</th></tr>
<tr><td><input type="text" name="oldcolor" disabled="disabled" id="oldcolor" /></td><td><input type="text" name="newcolor" id="newcolor" /></td></tr>
</table>
<div class="buttonrow">
<input type="hidden" name="page" value="{$PAGE}" />
<input type="hidden" name="module" value="changecolor" />
<input type="hidden" name="id" id="parameter_key" value="" />
<input type="submit" class="btnOk" value="Aanpassen" />
<input type="button" class="btnCancel" value="Annuleren" />
</div>
</form>
#NeXXeus, I already try it to do so (too big for a comment, and useful in the context of this question):
That's my placeholder in my .tpl file. and I call it as follow.
// color picker selecteren.
$(function(){
$("#color").dbclick(function(){
$('#colorpicker').farbtastic('#color');
});
});
<!-- new color form -->
<form action="controller.php" method="post" class="popupform" id="form_changecolor">
<div id="colorpicker"></div>
<table>
<tr><th>huidige:</th><th>nieuwe:</th></tr>
<tr><td><input type="text" name="oldcolor" disabled="disabled" id="oldcolor" /></td><td><input type="text" name="newcolor" id="newcolor" /></td></tr>
</table>
<div class="buttonrow">
<input type="hidden" name="page" value="{$PAGE}" />
<input type="hidden" name="module" value="changecolor" />
<input type="hidden" name="id" id="parameter_key" value="" />
<input type="submit" class="btnOk" value="Aanpassen" />
<input type="button" class="btnCancel" value="Annuleren" />
</div>
</form>
You question isn't very clear, this page has a very nice description on setting it up: http://acko.net/dev/farbtastic
Basing off of the example there, if you only want it to become a colorpicker when it is double-clicked...
$("#color").dblclick(function(){
$('#colorpicker').farbtastic('#color');
});
this is my form
<form name="thumbnail" action="<?php echo $_SERVER["PHP_SELF"];?>?complete=true" method="post">
<input type="hidden" name="x1" value="" id="x1" />
<input type="hidden" name="y1" value="" id="y1" />
<input type="hidden" name="x2" value="" id="x2" />
<input type="hidden" name="y2" value="" id="y2" />
<input type="hidden" name="w" value="" id="w" />
<input type="hidden" name="h" value="" id="h" />
<input style="margin-top:7px;" type="submit" name="upload_thumbnail" value="Save Thumbnail" id="save_thumb" />
</form>
and on the page i have this
<?php
print_r($_GET);
if($_GET["complete"] == "true"){ ?>
<script type="text/javascript">
parent.jQuery.fancybox.close();
</script>
<?php } ?>
but the get is always nothing..why is that when i add ?complete=true to the string
i tried GET POST but nothing....any ideas on how to do this
It works for me...
Array
(
[complete] => true
)
<script type="text/javascript">
parent.jQuery.fancybox.close();
</script>
So you have a problem somewhere else.
Also, if you are going to use <?php echo $_SERVER["PHP_SELF"];?> for your form, change it to <?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?> for security.
Otherwise, I may request index.php/"%20onsubmit="alert('xss');return%20false"%20bla=" which leaves your HTML looking like....
<form name="thumbnail" action="/stuff/euler.php/" onsubmit="alert('xss');return false" bla="?complete=true" method="post">
Maybe try === instead of ==
I would guess the string "true" gets evaluated as true (boolean)