i am using contact form 7 as a form builder. The requirement is when a user submit his form, after clicking the submit button there should open a new window that will display all his data that he has submitted. is there any solution for this?
I want the user submitted data in new tab so that he can veiw his submitted details
You can use Contact Form 7 custom DOM events to get the submitted data and output it on a new window.
Try out this javascript code . Tested and working.
document.addEventListener('wpcf7submit', function (event) {
var inputs = event.detail.inputs;
var output_html = '';
for (var i = 0; i < inputs.length; i++) {
output_html += inputs[i].name + ' : ' + inputs[i].value + '</br>';
}
var newWindow = window.open();
newWindow.document.write(output_html);
}, false);
Or add this in your theme's function.php
add_action('wp_footer', 'ze_cf7_data_in_new_tab');
function ze_cf7_data_in_new_tab(){
?>
<script>
document.addEventListener('wpcf7submit', function(event) {
var inputs = event.detail.inputs;
var output_html = '';
for (var i = 0; i < inputs.length; i++) {
output_html += inputs[i].name + ' : ' + inputs[i].value + '</br>';
}
var newWindow = window.open();
newWindow.document.write(output_html);
}, false);
</script>
<?php
}
I have a page in aspx which uses the following code. The issue is that it fetches the values from SQL and put into boxes using internet explorer but not doing using chrome
var element = document.getElementById("ctl00$pagecontent$Flexibleselect_Reol$ctl01");
//alert(element);
//alert('<%=Flexibleselect_Reol.Controls[1].ClientID %>');
element.onchange = (function(onchange) {
return function(evt) {
// reference to event to pass argument properly
evt = evt || event;
// new code "injection"
var puselectobj = document.getElementById('ctl00$pagecontent$Flexibleselect_Reol$ctl01');
var paramVal = puselectobj.value;
// alert(paramVal);
var newUrl = updateURLParameter('ProcessUnit', paramVal);
theForm.action = newUrl;
if (onchange) {
onchange(evt);
}
}
})(element.onchange);
// alert(element.onchange);
function updateURLParameter(param, value) {
var url = theForm.action;
var newAdditionalURL = "";
var tempArray = url.split("?");
var baseURL = tempArray[0];
var additionalURL = tempArray[1];
var temp = "";
if (additionalURL) {
tempArray = additionalURL.split("&");
for (i = 0; i < tempArray.length; i++) {
if (tempArray[i].split('=')[0] != param) {
newAdditionalURL += temp + tempArray[i];
temp = "&";
}
}
}
var paramVal = value;
var rows_txt = temp + "" + param + "=" + paramVal;
var querystr = "?" + newAdditionalURL + rows_txt;
return baseURL + querystr;
}
I am getting the following error when running in chrome
"Uncaught TypeError: Cannot read properties of null (reading 'onchange')"
We are using Gravity Forms to attach multiple images to a gallery custom field and create new post. We can't figure out how to show the image thumbnails under the import HTML5 import field instead of just the file names prior to form submission.
This previous answer covers only single file upload: gravity form preview of image upload
That mechanism is different it seems.
I also see GF offers a JS function to filter the image data returned but I can't figure out how to get the temporary img urls to display tags. That reference is here:
gform.addFilter('gform_file_upload_markup', function (html, file, up, strings, imagesUrl) {
var formId = up.settings.multipart_params.form_id,
fieldId = up.settings.multipart_params.field_id;
html = '<strong>' + file.name + "</strong> <img class='gform_delete' "
+ "src='" + imagesUrl + "/delete.png' "
+ "onclick='gformDeleteUploadedFile(" + formId + "," + fieldId + ", this);' "
+ "alt='" + strings.delete_file + "' title='" + strings.delete_file + "' />";
return html;
});
To show the preview of the image with just thumbnail size. You need to convert your image to the base64 so it will not take much time to load and it will show perfect.
/**
* Upload image action for Gravity Forms
* This script displays the thumbnail upon image upload for multi file field.
*
*/
function gravity_image_thumb() {
if ( is_page('slugname') ) {
?>
<script type="text/javascript">
gform.addFilter('gform_file_upload_markup', function (html, file, up, strings, imagesUrl) {
//alert(strings);
//Path of your temp file
var myFilePath = '/wp-content/uploads/gravity_forms/FormNameFolderURL/tmp/';
var formId = up.settings.multipart_params.form_id,
fieldId = up.settings.multipart_params.field_id;
var fileName = up.settings.multipart_params.gform_unique_id + '_input_' + fieldId +'_'+ file.target_name;
var fid = "fid"+ Math.ceil((Math.random() * (10000 - 1000)) + 1000);
//Converting Image to the base64
function convertImgToBase64URL(url, callback, outputFormat){
var img = new Image();
img.crossOrigin = 'Anonymous';
img.onload = function(){
var canvas = document.createElement('CANVAS'),
ctx = canvas.getContext('2d'), dataURL;
canvas.height = (300 * img.height)/img.width;
canvas.width = 300; //img.width;
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
dataURL = canvas.toDataURL(outputFormat);
callback(dataURL);
canvas = null;
};
img.src = url;
}
convertImgToBase64URL(myFilePath + fileName , function(base64Img){
var ffid = "#"+fid;
$(ffid).attr("src", base64Img);
console.log('RESULT:', base64Img);
});
html = '<img id="'+fid+"\" src='' style='width:100%;height:auto;'/><img class='gform_delete' " + "src='" + imagesUrl + "/delete.png' "+ "onclick='gformDeleteUploadedFile(" + formId + "," + fieldId + ", this);' " + "alt='" + strings.delete_file + "' title='" + strings.delete_file + "' />";
return html;
});
</script>
<?php }
}
add_action('wp_head','gravity_image_thumb');
Have you found a Solution for this?
If not, I would like to share mine:
gform.addFilter('gform_file_upload_markup', function (html, file, up, strings, imagesUrl) {
var myFilePath = 'https://your-domain.com/wp-content/uploads/gravity_forms/1-0bfa8914c61ec9b6ff8b3e2c78f497f4/tmp/';
var formId = up.settings.multipart_params.form_id,
fieldId = up.settings.multipart_params.field_id;
var fileName = up.settings.multipart_params.gform_unique_id + '_input_' + fieldId +'_'+ file.target_name;
html = '<img src="' + myFilePath + fileName + "\"/>' <img class='gform_delete' "
+ "src='" + imagesUrl + "/delete.png' "
+ "onclick='gformDeleteUploadedFile(" + formId + "," + fieldId + ", this);' "
+ "alt='" + strings.delete_file + "' title='" + strings.delete_file + "' />";
return html;
});
I am using the image in /tmp, because that's the folder where the Image gets uploaded before the Form is submitted completley.
/{some-numbers-and-letters}/
this is the Folder where the tmp Folder is located. I guess you can change that.
I have a basic chat that reads from a database. Each chat message is read from the database by this.
<span>{{formatChat text}}</span>
text being the message read.
And then I use the formatChat registerHelper to detect URLs.
Template.registerHelper('formatChat', function(text) {
var urlRegex = /https?:\/\/([a-zA-Z0-9\-\.]+)(\.[a-zA-Z0-9]+)((([a-zA-Z0-9\?\=\/])+)?((\#|\?)(.+)?)?)?$/
var urlRegexMini = /(www(\d{0,3})\.)?([a-zA-Z0-9\-\.]+)(\.(com|net|org|gov|co\.uk|edu|io\b)+)([a-zA-Z0-9\?\=\/]+((([a-zA-Z0-9\?\=\/])+)?((\#|\?)(.+)?)?)?)?$/
finalString = "";
//Parse every word individually
split = text.split(' ');
for (i = 0; i < split.length; i++) {
finalString += " ";
if (urlRegex.test(split[i])) {
finalString += "<a href='" + split[i] + "'>" + split[i] + "</a>";
}
else if (urlRegexMini.test(split[i])) {
finalString += "<a href='http://" + split[i] + "'>" + split[i] + "</a>";
}else{
finalString += split[i];
}
}
return finalString.substring(1,finalString.length);
});
The problem is that meteor doesn't allow injection, so it will literally show the anchor tag as plain text.
One solution that I thought of was to have a registerHelper for each individual word, but that seems rather foolish.
How can I efficiently get around this rule?
I believe this should do it:
{{{formatChat text}}}
The code below is for getting a Json string for the selected rows in a grid.
However this feels rather clumsy or is the way to go for extjs 4?
var json = "[";
var selrows = g.getView().getSelectionModel().getSelection();
for (var r=0; r<selrows.length; r++) {
var selrow = selrows[r];
json += "{";
for (var f=0; f<selrow.fields.length; f++) {
var n = selrow.fields.items[f].name;
var v = selrow.data[n];
json += "'" + n + "' : '" + v + "',";
}
json += "},";
}
json += "]";
alert(json);
In Firebug I see a json-alike representation of the selrow var but I can't seem to get hold of it in javascript.
Try this:
json = Ext.JSON.encode(g.getView().getSelectionModel().getSelection().map(function(e){ return e.data; }));
alert(json);