I've got a jotform that I want to prepopulate fields.
This code works, but I want to dynamically update the name after the "=".
<script type="text/javascript"
src="https://form.jotform.com/jsform/202786957650165?fullName3[first]=Tony">
</script>
let's assume I can grab the name from the url, such as https://example.com?Tony using the following
var fname = window.location.search.substr(1)
my question is how do I get the name added to the JS?
This doesn't work:
<script type="text/javascript"
src="https://form.jotform.com/jsform/202786957650165?fullName3[first]="+fname>
</script>
any ideas?
Related
I am creating a page that displays users based on a view and I would like to add a button to this view that will send off an email that has the subject filled in with the name of the site and some other text. Maybe even prefill some of the body.
I do not want to create a new field in the list because only a small portion of records will leverage this attribute (only those contacts that have a support role). The view only displays support role individuals. I tried to change the existing email link by adding the appropriate information, but I have no clue how to do this. My next attempt was to add a button and then code behind this button. This has to be only client changes, nothing with master pages. This is the code I have. I can call an alert, but not able to put my email string in their to make it work or to call a local js function. Neither one of these work.
I'm know JS, but I'm no master
<script language="javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function(){
document.getElementById('pageTitle').innerHTML=document.title;
_spBodyOnLoadFunctionNames.push("buttons");
});
function buttons()
{
var $t = $('#js-listviewthead-WPQ2').next().next().find('tr');
$t.each(function(){
// $(this).append("<input type='button' value='Help' id='btnSub' onclick='alert(document.title);'/>");
$(this).append("<input type='button' value='Help' id='btnSub' onclick='Steve#wi.gov'>");
});
}
</script>
Email opens up with the subject pre-filled.
We can use the code below to achieve it.
<script src="https://code.jquery.com/jquery-1.12.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
addButtons();
});
function addButtons(){
var listTitle="CustomList";
$("table.ms-listviewtable[summary='"+listTitle+"']>tbody>tr").each(function(){
$(this).append("<input type='button' value='Help' id='btnSub' onclick='javascript:openMail();'>");
});
}
function openMail(){
location.href="mailto:Steve#Wi.gov?subject=SharePoint Site Support";
}
</script>
I am trying to use GTM's "Custom HTML Tag" option with the following code but it is giving me the following error: Invalid HTML, CSS, or JavaScript found in template.
I've seen other threads where it looks like GTM doesn't work well with certain tag attributes. I'm wondering which one in my code is breaking it. Otherwise the code seems to be standard javascript:
<!-- Add script to header tag-->
<script type="text/javascript" src="https://staygrid.com/js/hapi/web.js?v="20150809"></script>
<script type="text/javascript">
var hlWebEngine = new HotelogixWeb();
function drawEngine()
{
var options = {
container: document.getElementById("webDiv"),
hotelId: "QV5TX0ZSczM0Xzc5Nl9GNXRlcjkwODdzXylkaGZfZHJ0ZXI3Xzc5Nl9oZ2ZoX2deZDg1NA==",
languageId: 1
};
hlWebEngine.draw(options);
}
hlWebEngine.run(drawEngine);
</script>
<!--Div that will hold the web engine-->
<div id="webDiv" style="border-width: 0"></div>
Remove the extra double quotes before your "v" query parameter value, so that it looks like this:
src="https://staygrid.com/js/hapi/web.js?v=20150809"
At least that did the trick for me when I tried it out in my own container.
your src attribute use like given below i think it will work
<script type="text/javascript" src="https://staygrid.com/js/hapi/web.js?v='20150809'"></script>
I have used this tutorial to create a JS based widget. One thing I need to do is to pass query string parameters in JS file. I tried document.location.href but it gave the URL of page where widget was placed(which is quite obvious)
Code is given below:
<script src="http://example.com/widget.js?id=2" type="text/javascript"></script>
<div id="widget"></div>
I need to fetch id=2 which I can pass further.
Thanks
If you give your script an id then you can write:
<script src="http://example.com/widget.js?id=2" id="myscript" type="text/javascript"></script>
<div id="widget"></div>
<script>
var myScript = document.getElementById('myscript');
var src= myScript.getAttribute('src');
//Get the id from the src based on parameter using Regular Expression
</script>
I know this question are asked hundreds of times :( but I just want to learn more :).
My question is simple, can I pass a value to a js file like this, if not, how ?
<script type="text/javascript" src="./js/create.js?method=create"></script>
Yes, you notice that I have a parameter method=create which I want to use in my create.js.
I know in jquery ajax, we have an easy way, but you must notice that the ajax method is in included in the js file, how could I pass a parameter to the js file itself ?
Any answer is welcome :)
Thanks.
This works perfect for me:
<script src="js/script.js" id="myScript" data-url="my_variable"></script>
inside the script.js file:
var myUrl = document.getElementById("myScript").getAttribute( "data-url" );
"myUrl = my_variable" inside the code
you can use myUrl everywhere.
Not really, no. What you can do is this:
<script type="text/javascript">
var method = "create";
</script>
<script type="text/javascript" src="./js/create.js"></script>
Another way is to only define functions inside your javascript file, and then invoke after it has loaded.
<script type="text/javascript" src="./js/create.js"></script>
<script type="text/javascript">
runMyLoadedCode("create");
</script>
Third way is belying my first simplistic answer: access the script tag itself and parse it. You can see here how to access the tag that has loaded your script; take its src value and cut it up to locate your method=create.
Good day!
I have recently acquired a code and was passed on using fiddle. It works fine on the fiddle but when I am trying to implement it on my site.
Head tag contains:
<head>
<title>NQA Insert</title>
<script type="text/javascript" src="NQAa.js">
</script>
</head>
While NQA.js contains:
$('#bill50').on('change', function() {
var date30 = new Date($(this).val());
date30.setDate(date30.getDate()+30);
var date20 = new Date($(this).val());
date20.setDate(date20.getDate()+60);
$('#bill30').val(date30.toJSON().slice(0,10));
$('#bill20').val(date20.toJSON().slice(0,10));
});
Note 1: If you input a date on bill50, the value on bill30 and bill20 also changes.
Note 2: I am implementing this on a php page. Maybe this helps...
Why is it that when implementing it on the site, it doesn't work at all? Is there anything wrong in my calling of the jscript..?
you need to include the jQuery library, as you can see in your jsFiddle he's including jQuery 1.8.3, you should add it in your "head" tag just before the js script you bought.
You'll get something like this:
<head>
<title>NQA Insert</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.min.js">
<script type="text/javascript" src="NQAa.js">
</script>
</head>