Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

open url with field variable

Questions related to using nuBuilder Forte.
Post Reply
amit
Posts: 36
Joined: Sat Jun 02, 2018 1:26 pm

open url with field variable

Unread post by amit »

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.
btnopen.png
You do not have the required permissions to view the files attached to this post.
nac
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

Unread post by nac »

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.

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');
}
I hope this helps.

Neil
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: open url with field variable

Unread post by admin »

.
Post Reply