Javascript link in drupal view - javascript

I'm telling the view to display a field with the NID contents. I'm telling it that I wish to "Rewrite the output of this field" and I enter:
<a href=”javascript:void(0);” onclick="javascript: approve([nid])" >Approve</a>
When viewing the page, all the javascript has been stripped. How do I get views to accept javascript in the link, or what other way can I use to display a link?
Note: Custom Text field doesn't work either.

Found the solution! http://drupal.org/project/views_customfield
From the description:
This module provides some useful (views)fields.
Available (views)fields:
Markup
Field that allows usage of custom text and the input filter system.
PHP code
Field that allows usage of custom PHP code (with access to view's database result)
Rownumber
Field containing rownumber (respects pagers).

Related

How do I pass an email into the site tracking Javascript code?

does anyone here have any idea how to set up Site Tracking by passing a contact's email address into Javascript Code?
I am on Wordpress using the visual builder Elementor's native contact form.
Here's the contact form: https://www.bestseo.sg/free-report/ (Bottom of the page)
I have already inserted ActiveCampaign's site tracking code sitewide.
However, it does not seem to start site tracking even after the form submission.
According to ActiveCampaign's documentation(https://help.activecampaign.com/hc/en-us/articles/221542267-An-overview-of-Site-Tracking#how-to-pass-a-contact-s-email-address-into-javascript-code), I believe I have to add this line of code:
vgo('setEmail', 'Email_Address_Goes_Here');
above
vgo('process');
But I have no idea what to replace 'Email_Address_Goes_Here' with, in order to call the actual contact's email after form submission.
Any help would be much appreciated!
Thank you.
So the plugin used to insert these JavaScript codes is https://wordpress.org/plugins/header-and-footer-scripts/ - I’d suggest to maybe just keep using that, and keep the scripts in the footer, so that this does not require too much modication.
Inside your template, you have to output the email addresse somewhere, where the JS can read it from - via a custom data attribute added to the body element for example.
The header.php of your theme should contain something similar to
<body <?php body_class(); ?>>
Modify that, to add a custom data attribute to store the email address entered in the from:
<body <?php body_class(); ?> data-freereportemail="<?php echo !empty($_POST['form_fields']['email']) ? esc_attr($_POST['form_fields']['email']) : ''; ?>">
If the POST parameter by that name is set, then it will be output as content of this attribute, otherwise it’ll simply stay empty.
Then modify the JavaScript code you insert via the plugin like this,
var freereportemail = $('body').attr('data-freereportemail');
if( freereportemail != '' ) {
vgo( 'setEmail', freereportemail );
}
This assumes that jQuery has already been loaded at this point, but I think that should most likely be the case.
If the attribute contained an email address, then this will execute the vgo tracker function, if the attribute value is empty, then it will simply skip this call.
This is not the most sophisticated approach, but it should do.
(Only if you had other forms on the site as well, that use a form field of that exact same name, you might be tracking more than intended. In that case, you’d need to find some additional criterion, to be able to differentiate between these different forms.)
A person at the AC support gave me thsi code :
jQuery('form').submit(function() {
var userEmail = jQuery("form input[type='email']").val();
vgo('setEmail', userEmail);
vgo('process');
});
I hope it'll help you.
I use FluentForms, so i just went on the form specific Custom JS/CSS to apply it (so i had no problems of proper targeting...)

Jira like autocomplete for textarea

I want to implement Jira like auto complete behavior for one of my pet project.
Check following screenshot.
I have searched hard for any existing plugin that could able to deliver it but couldn't find anyone.
I have tried following things (JsFiddle Link):
Add textarea and input(hidden initially) field elements.
Bind a keyPress event on textarea
Capture # key and showing input field enabled with jQuery#autocomplete plugin with list of users
HTML:
<div class='span12'>
<textarea id='comments' class='span12'></textarea>
<input id='users' class='span12 hide' />
</div>
Script:
$(function() {
var users = [
"Ram",
"Ramesh",
"Rakesh",
"Rahul",
"Abhi",
"Karan"
];
$('#comments').on('keypress', function(e){
if(e.keyCode === 64) {
$( "#users" ).removeClass('hide');
$( "#users" ).autocomplete({
source: users
});
}
});
});
My questions are:
How can we trigger #text to show auto-complete list with text as selected?
After selecting the user, how we can insert that user name in the textarea?
Following are the three JavaScript plugins I found which serves the purpose I am looking for:
jQuery-textcomplete.js
At.js
triggeredAutocomplete.js
A great implementation with a UI just like this is jquery.mentionsInput.
It works with arrays of objects to auto-suggest as well as content fetched via AJAX requests. It requires jQuery and underscore.js and supports MSIE 8 and better.
Of particular note is it that exports links to usernames using a simple Markdown style markup, storing internal ID's alongside the #username mention. This means you can easily parse the text to do things like trigger events based on who is mentioned and means you can display real, human readable names in text but still correlate them with unique user ID's internally.
Any Markdown library can convert it to plain text if you need to just store or display the result as plain text.

Autopopulate form input texboxes with javascript

I have this following problem because I don't have expertise in Javascript
I'm testing a Facebook login at
http://goo.gl/3R3owa
After the user is logged in Facebook an alert windows with the birthday and location comes up. So far so good.
Rather than show that window i will like to autopopulate the day, month and year input boxes in that page.
Is there any way to do that?
Here is my code
http://goo.gl/IFhJdu
Thanks in advance!
Assuming that you have all the data in the response object and element_id# is a valid id of an element present on the HTML page. You can simply use following JS code do set the value of an input field in JS:
document.getElementById('element_id1').value = response.gender;
document.getElementById('element_id2').value = response.birthday;
document.getElementById('element_id3').value = response.location.name;
Similarly, for feeding the data to an HTML element, you can use innerHTML, for example:
document.getElementById('element_id1').innerHTML= response.gender;
(You can use the above code to replace the alert() method in you JS code.)

How can I call Javascript inside formsweb.cfg?

In the Changing the Browser title I read that it is possible to dynamically change the "pageTitle" of the "formsweb.cfg" with the help of Javascript.
My aim is to dynamically show the name of the oracle forms (10g) in the browsers page title. How can I use a function like this
# HTML page title
<script>
function setWindowTitle(x)
{
document.title=x;
}
</script>
setWindowTitle(form);
in my formsweb.cfg to return the form name and set it in the browser title?!!!!
Does anybody know how I can do it?
I appreciate any kind of help
You can change your title in the base.htm file or whatever you're using as a file.
Here you can also use javascript because it is a normal html file.
For the title depending on data or so you can use cookies.
You can create it from triggers and you can also read it with javascript.
You can see some examples of manipulating the applet browser window dynamically here:
http://oracleformsinfo.wordpress.com/2011/12/25/getting-the-browser-window-under-control-when-separateframetrue/
If you would like to pass parameters from the Forms itself such as the Form name you must be using Forms 11g and use javascript to send the Form name to the page itself.
For a solution in Forms 4.5 - 10g you can set the Form window title very easily to be the Form name using get_application_property to get the form name and then set_window_property to set the Form window title.

Calling a javascript file (.js) via Excel VBA?

How to call a javascript file (.js) via Excel VBA?
So as i am opposed to the same kind of problem i'll try to submit you guys my case.
I am trying to automate datas extraction from valeo's catalogue using excel vba macro.
I have a list of références attached to valeo's automotive products (huge list, as more than 3000 thousands items). And i would like to import directly informations from the catalogue wich seems to run under javascript.
The datas i need is the list of every vehicules attached to a reference.
Here is the url: http://outcat-cs.tecdoc.net/ows/en/7FA2A0C501BC34CA4BECB04095663CF1.ows_cs2.srv?view=VIndexFramesetJsp
I'd like to access to the "Direct Article Search" tab, in order to copy a reference directly from an excel tab's cell and then simulate a clic on the reference in order to display the "linked vehicules section" and then to copy them in a new excel sheet.
I already succeede in doing this with html pure programmed webpage (oscaro.com) using the following code :
Set maPageHtml = IE.document
Set Helem = maPageHtml.getElementsByTagName("input")
For i = 0 To Helem.Length - 1
If Helem(i).getAttribute("name") = "toFind" Then Helem(i).Value = "819971" '819971 is the valeo reference searched
If Helem(i).getAttribute("name") = "submit" Then Set Monbouton = Helem(i)
Next
Monbouton.Click 'this does the click on my button Monbouton
But this technique can't be used with valeo website since I am not able (or at least I don't know yet how to do it) to select/click a button when the page is made on javascript, since it doesn't have a name, value or id for the button.
Also it seems that the url in the address field is the same before clicking on the "Direct Article Search" button and after having clicked....
Hope i am clear enought in spite of my english...
Greetings
All the previously suggested approaches sound hacky to me.
For a more reliable solution, embed the Javascript in a COM component via Windows Script Components, and call the Javascript-based COM component as you would any other COM component.
I don't think that there is a direct way to run JavaScript code in VBA.
What you could try to do is to embed the JavaScript code in an HTML form which you could open in a (hidden) browser control. Then fill the form controls via the DOM of the browser control and submit the form. The submit triggers the JavaScript function that you want to call.
Sample (not tested):
VBA:
oIE.Document.frmMain.param1.Value = 5
oIE.Document.frmMain.param2.Value = "6"
oIE.Document.frmMain.submit.click ' this line will call the JavaScript function
HTML:
<div id="submit" > Do Action</div>
<script>
function doAction()
{
// do whatever the code should do
}
</script>
You mean through windows scripting host?
You can shell (use the shell command) out to wscript.exe with the name of the .js file.
But this javascript object model won't be like the one you get in the browser.
It would be helpful if you told us what the javascript was supposed to do.

Categories