onclick error

Use this board to ask questions or have discussions with other Rich Displays users.
Post Reply
edalakiran
New User
Posts: 16
Joined: Fri Nov 03, 2017 5:09 pm
First Name: Teja
Last Name: Edala
Company Name: win
City: Cincinnati
State / Province: Ohio
Zip / Postal Code: 45249
Country: United States
Contact:

onclick error

Post by edalakiran »

Hi,

can anyone explain me, i am writing some function in the "Onclick event" example
"viewLink = function viewLink(xxxxx, xxxx, xxx, xxx, xxx, xxx, xxxx) " like this and i wrote some function in the javascript like

var viewLink = function viewLink(xxxxx, xxxx, xxx, xxx, xxx, xxx, xxxx){
console.log("test")
}

but i am getting some error i don't understand " unexpected end of input"

any help would be appreciated.

Thanks
Kiran.
ZoeW
Profound User
Posts: 24
Joined: Thu Jan 07, 2016 9:24 am
First Name: Zoe
Last Name: W
Company Name: Previously Anker International
Country: United Kingdom
Contact:

Re: onclick error

Post by ZoeW »

Firstly, you are missing the ; after console.log("test"), however, I'm not an expert on JavaScript, but I find this website useful: http://jshint.com/
Paste in your code and it will tell you what is wrong.
edalakiran
New User
Posts: 16
Joined: Fri Nov 03, 2017 5:09 pm
First Name: Teja
Last Name: Edala
Company Name: win
City: Cincinnati
State / Province: Ohio
Zip / Postal Code: 45249
Country: United States
Contact:

Re: onclick error

Post by edalakiran »

Hi, thank you for your reply, when i click even it is not entering into that function ,
User avatar
matt.denninghoff
Profound Logic Staff Member
Posts: 115
Joined: Wed Feb 10, 2016 3:53 pm
First Name: Matthew
Last Name: Denninghoff
Company Name: Profound Logic Software
State / Province: Ohio
Country: United States
Contact:

Re: onclick error

Post by matt.denninghoff »

I think you've only defined the function, and you haven't called it. When you write a line like this:

Code: Select all

var viewLink = function(/*params here*/){/*some code here*/}
Then that simply defines a function named viewLink. If you want to call the function after it's defined, then you'd need to add a call to it:

Code: Select all

viewLink(/*some arguments here*/);
However, I don't understand why you are bothering defining a function within the "onclick" and then immediately calling it. Why not just put some code inside the "onclick" and avoid defining a function. In your case, why not just put this as your "onclick" code:

Code: Select all

console.log("test");
You need to define a function if you are calling the same code from multiple events or locations. If you are reusing it, then you'd want to define it somewhere besides the "onclick" event--for example, in a custom.js file.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests