Problem with my click element in Javascript - javascript

I can't make an alert in JS when clicking on the "Submit" button. It's html loaded remotely by a script and the JS can't recognize it.
Here is a reconstruction, anyone have an idea please? http://jsfiddle.net/sdrvqjxn/1/
<script charset="utf-8" type="text/javascript" src="//js-eu1.hsforms.net/forms/embed/v2.js"></script>
<script>
hbspt.forms.create({
region: "eu1",
portalId: "26927362",
formId: "46123717-093e-4314-9afb-d71fc6e2e40f"
});
</script>

Set the onFormSubmit option:
hbspt.forms.create({
region: "eu1",
portalId: "26927362",
formId: "46123717-093e-4314-9afb-d71fc6e2e40f",
onFormSubmit() {
alert('submit');
}
});

Related

What's wrong with this code? It's doing nothing

<HTML>
<HEAD>
<script>
$(function(){
$(window).on('hashchange', function() {
var hash = location.hash.replace( /^#/, '' );
document.title = 'example ' + hash;
});
$(window).trigger('hashchange');
});
</script>
<TITLE>example</TITLE>
</HEAD>
<BODY>
</body>
</HTML>
Let's say the <title> of example.com is example
This code should automatically update the page title for example.com/#city1 to example city1 and example.com/#city2 to example city2 and so on.
I have only an index.html file and I don't want to add php file to my html file.
As said in the comments you need to add the jQuery library to your page using :
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js">
Then your code should work as expected.

Credit card integrate visa & masercard

I want to use pay by creditcard but I haven't any progress in my task.
this is my code that I try but nothing happen.
<html>
<head>
<script type="text/javascript">
function onVisaCheckoutReady(){
V.init( {
apikey: "7O07VN664O10JW6A9ESS113p8sf9JeGzr6_2haC9F9m_ANtLM",
paymentRequest:{
currencyCode: "USD",
total: "10.00"
}
});
V.on("payment.success", function(payment) {
alert(JSON.stringify(payment));
});
V.on("payment.cancel", function(payment) {
alert(JSON.stringify(payment));
});
V.on("payment.error", function(payment, error) {
alert(JSON.stringify(error));
});
}
</script>
</head>
<body>
<img alt="Visa Checkout" class="v-button" role="button"
src="https://sandbox.secure.checkout.visa.com/wallet-services-web/xo/button.png"/>
<script type="text/javascript"
src="https://sandbox-assets.secure.checkout.visa.com/checkout-widget/resources/js/integration/v1/sdk.js">
</script>
</body>
</html>
any one can help me ?
and also I get some code from Visa official site but can't understand to use that.
You can simply sue stripe-php library to configure any type of credit Card that you want it is so easy and very responsive by each gateway payment service.

How to call other js method in Index.cshtml page button onclick?

I have added js file bootstrap-notify.js file link which is having Notify function which generates notification dynamically.
I'm able to call that notify function on page load but when I try to execute it on button click getting error :Uncaught TypeError: $.notify is not a function
any clue why is it so?
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="~/Scripts/bootstrap-notify.js"></script>
<script type="text/javascript">
function myfun() {
debugger;
$.notify({
icon: 'glyphicon glyphicon-warning-sign',
title: 'Bootstrap notify',
message: 'Turning standard Bootstrap alerts into "notify" like notifications'
}, { type:'success', delay: 1000, timer: 2000
});
}
</script>
<div>
<button type="button" onclick="myfun();">TEST</button>
</div>

#Mention.js returns no result

I tried using Mention.js from this.
My Search.html contains,
<!DOCTYPE html>
<html>
<body>
<div>
<textarea id="try"></textarea>
</div>
<script type="text/javascript" src="http://jakiestfu.github.io/Mention.js/javascripts/bootstrap-typeahead.js">
$('#try').mention({
delimiter: '#',
users: [{
username: "ashley"
}, {
username: "roger"
}, {
username: "frecklefart123"
}]
});
</script>
</body>
</html>
The box returns no result. Any help in pointing my mistake is appreciated. Thanks.
P.S This is pseudocode, the actual usage is in my rails app in search.html.erb which has Typeahead dependancy.
As the documentation of Mention.js
Dependencies
jQuery ,
Typeahead
so you should use
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript" src="http://jakiestfu.github.io/Mention.js/javascripts/bootstrap-typeahead.js"></script>
then the plugin
<script type="text/javascript">(function(e){e.fn.extend({mention:function(t){this.opts={users:[],delimiter:"#",sensitive:true,queryBy:["name","username"],typeaheadOpts:{}};var n=e.extend({},this.opts,t),r=function(){if(typeof e=="undefined"){throw new Error("jQuery is Required")}else{if(typeof e.fn.typeahead=="undefined"){throw new Error("Typeahead is Required")}}return true},i=function(e,t){var r;for(r=t;r>=0;r--){if(e[r]==n.delimiter){break}}return e.substring(r,t)},s=function(e){var t;for(t in n.queryBy){if(e[n.queryBy[t]]){var r=e[n.queryBy[t]].toLowerCase(),i=this.query.toLowerCase().match(new RegExp(n.delimiter+"\\w+","g")),s;if(!!i){for(s=0;s<i.length;s++){var o=i[s].substring(1).toLowerCase(),u=new RegExp(n.delimiter+r,"g"),a=this.query.toLowerCase().match(u);if(r.indexOf(o)!=-1&&a===null){return true}}}}}},o=function(e){var t=this.query,r=this.$element[0].selectionStart,i;for(i=r;i>=0;i--){if(t[i]==n.delimiter){break}}var s=t.substring(i,r),o=t.substring(0,i),u=t.substring(r),t=o+n.delimiter+e+u;this.tempQuery=t;return t},u=function(e){if(e.length&&n.sensitive){var t=i(this.query,this.$element[0].selectionStart).substring(1),r,s=e.length,o={highest:[],high:[],med:[],low:[]},u=[];if(t.length==1){for(r=0;r<s;r++){var a=e[r];if(a.username[0]==t){o.highest.push(a)}else if(a.username[0].toLowerCase()==t.toLowerCase()){o.high.push(a)}else if(a.username.indexOf(t)!=-1){o.med.push(a)}else{o.low.push(a)}}for(r in o){var f;for(f in o[r]){u.push(o[r][f])}}return u}}return e},a=function(t){var r=this;t=e(t).map(function(t,i){t=e(r.options.item).attr("data-value",i.username);var s=e("<div />");if(i.image){s.append('<img class="mention_image" src="'+i.image+'">')}if(i.name){s.append('<b class="mention_name">'+i.name+"</b>")}if(i.username){s.append('<span class="mention_username"> '+n.delimiter+i.username+"</span>")}t.find("a").html(r.highlighter(s.html()));return t[0]});t.first().addClass("active");this.$menu.html(t);return this};e.fn.typeahead.Constructor.prototype.render=a;return this.each(function(){var t=e(this);if(r()){t.typeahead(e.extend({source:n.users,matcher:s,updater:o,sorter:u},n.typeaheadOpts))}})}})})(jQuery)</script>
or just download the Mention.js file and link it to your code
and then
<script>
// run your code here
</script>
$('#try').mention({...)};it should be in $( document ).ready().

external JS does not work

I have the following code:
<script language="javascript" type="text/javascript">
$.fn.dataTableExt.oPagination.input = {
"fnInit": function (oSettings, nPaging, fnCallbackDraw) {
....
},
"fnUpdate": function (oSettings, fnCallbackDraw) {
....
}
};
</script>
and it works, but when I create external file and put this code inside this file (of course without <script></script> ) - it does not work. Why?
just make sure the jQuery is the first script you load
<script type="text/javascript" src="jquery.js"><scrip>
<script type="text/javascript" src="yourScript.js"><script>

Categories