Hi guys,
I have a problem. I'm trying to open a website when a button is clicked. So I added an onclick event to the button that calls window.open .
The website opens but my variable, #cust_product# is not resoloved, it should be replaced with the content of the field on my form.
Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
open url with field variable
-
- Posts: 36
- Joined: Sat Jun 02, 2018 1:26 pm
open url with field variable
You do not have the required permissions to view the files attached to this post.
-
- Posts: 115
- Joined: Tue Dec 12, 2017 11:28 pm
- Location: Aberdeen, UK
- Has thanked: 9 times
- Been thanked: 12 times
Re: open url with field variable
Amit,
Here is how I did something similar. I was using an input:URL object to store the URL and doubleclick on it would run the code below to open the website. You could easily attach this code to a button onclick and pull the URL from another field if you wish. I am assuming that cust_product holds the URL you wish to open.
I hope this helps.
Neil
Here is how I did something similar. I was using an input:URL object to store the URL and doubleclick on it would run the code below to open the website. You could easily attach this code to a button onclick and pull the URL from another field if you wish. I am assuming that cust_product holds the URL you wish to open.
Code: Select all
var myURL = $("#cust_product").val(); // change to your object name as required
// var myURL = $(this).val(); // use 'this' if it is the element itself that is clicked
if (myURL.length > 0) {
if (myURL.indexOf("://") < 0) { // check to see if the scheme prefix is present.
myURL = "http://" + myURL // if not add http.
}
window.open(myURL, '_blank');
}
Neil