aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Dynamically change the class according to the variables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Dynamically change the class according to the variables" Watch "Dynamically change the class according to the variables" New topic
Author

Dynamically change the class according to the variables

Sumer Selvaraj
Greenhorn

Joined: May 02, 2013
Posts: 15
Hi,

I'm developing a Web application. As you see the picture I kept the menus as tabs in a separate file and called it to the main page using code.


there is no issue in it. I wanted to change the tabs classes according to the variables in the URL. I gave a try with javascript & jquery but it didn't work.

Banner File


Javascript File


I want to change add the current class the tabs which selected. Can some one help on this???
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61226
    
  66

At what point is it going wrong? Are the "parts" as you expected after the regex? Why are you using the replace() method?

Open the debugging console in your browser and set breakpoints in the code. That way you can look at the value of variables and find out at what point it is going wrong. Why guess when you can actually inspect the variable at run time?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Sumer Selvaraj
Greenhorn

Joined: May 02, 2013
Posts: 15
Bear Bibeault wrote:At what point is it going wrong? Are the "parts" as you expected after the regex? Why are you using the replace() method?

Open the debugging console in your browser and set breakpoints in the code. That way you can look at the value of variables and find out at what point it is going wrong. Why guess when you can actually inspect the variable at run time?


There is no issue in getUrlVars() method. It returns the URL variables. I'm quite sure there is something wrong with the code
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61226
    
  66

Please make sure that the code you post is properly indented.

Did you open the debugging console? What error messages did you get?
Sumer Selvaraj
Greenhorn

Joined: May 02, 2013
Posts: 15
Bear Bibeault wrote:Please make sure that the code you post is properly indented.

Did you open the debugging console? What error messages did you get?


I've got the following error message on the console

Uncaught TypeError: Object #<HTMLUListElement> has no method 'removeClass' common_javascript.js:8
Got message from bg page - https://mail.google.com/mail/?view=cm&fs=1&tf=1 mailto.js:51
Starting to rewrite mailtos
Sumer Selvaraj
Greenhorn

Joined: May 02, 2013
Posts: 15
Bear Bibeault wrote:Please make sure that the code you post is properly indented.

Did you open the debugging console? What error messages did you get?


Further I have changed the script as follows


And now I am getting error as : "Uncaught ReferenceError: element is not defined"
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61226
    
  66

Elements do not have an addClass method. You need to wrap the element with jQuery to use jQuery methods. E.g. $(element).addClass()
Sumer Selvaraj
Greenhorn

Joined: May 02, 2013
Posts: 15
Bear Bibeault wrote:Elements do not have an addClass method. You need to wrap the element with jQuery to use jQuery methods. E.g. $(element).addClass()


Thank you. I worked
Sumer Selvaraj
Greenhorn

Joined: May 02, 2013
Posts: 15
Found a solution for this problem. I was coming around the bush. Now I've hit the bush. The following code helped me to overcome this issue

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dynamically change the class according to the variables