• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Javascript: setting variables with selectable table issue

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everyone, I have had this problem for over a week and have not found a solution that will work the way I want it to.

using html I have created a selectable table, which I would like to send the index of the row to a servlet once it has been submitted.
example: if row 1 is selected then on submit the user is redirected to "productServlet?rowid="+row;

I want this variable to be set when a <tr onclick> is initiated, and changed accordingly if another row is clicked. the redirect to the servlet
also must be done in javascript as I have 3 different submit buttons that do 3 different things with the selected row. this part is sorted out
I have a function called setTarget(target) which redirects to the proper servlet depending on the value.

The problem is I am unable to get the onclick function variable in the setTarget(target) function. If I was to call a row(rowid) function inside setTarget then I would need the rowId in the first place so it wont work....

Please if anyone could help me or even point me in the right direction I would much appreciate it. I have spent 8+ hours trying to get this to work.
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sounds like you are making things much harder than they need to be. On the other hand, I can't really understand what you are trying to do.

Rather than a stream of consciousness -- please post the steps that you want the code to take on the click event.
 
matt larkin
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well The way my team has this interface set up you simply click from a selection of products in the selectable table.

Once a product is selected you may click the modify button, the show details button, or the delete button. in each of these cases
I have a redirect to a servlet which deals with the selected row accordingly. But for this to happen I cant simply redirect when someone
clicks a row as there are multiple options to choose from. This could be done easily with a listbox but formatting is not the same and
listboxes simply look like crap.

each row has a number associated to it(0,1,2,3) and when I redirect to the servlet I need to know which row was selected, either by setting the variable in a session which I dont think is possible, or send it in the url, but I dont kno how to get that variable into a url.

hopefully that explains it well enough
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

matt larkin wrote:each row has a number associated to it(0,1,2,3)

How?

Once a product is selected you may click the modify button, the show details button, or the delete button. in each of these cases
I have a redirect to a servlet which deals with the selected row accordingly. But for this to happen I cant simply redirect when someone
clicks a row as there are multiple options to choose from.

Explain "multiple options".
 
matt larkin
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well I set the value of the tr to the index value in my for loop which populates the table. as well I have the same list in my servlet so the referenced selection in my table matches the arraylist in my servlet.

As for multiple options I mean the 3 buttons to choose from, each goes to the same servlet but with different attribute values. If you read through my post you should understand what im trying to accomplish
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

matt larkin wrote:well I set the value of the tr to the index value

<tr> elements do not have values. What do you mean by this? Maybe you should start to show some code (Please use code tags).

As for multiple options I mean the 3 buttons to choose from, each goes to the same servlet but with different attribute values.

How does this prevent you from submitting a simple request as you stated earlier?

If you read through my post you should understand what im trying to accomplish

I'd re-evaluate your approach. Being snarky to people who are trying to help you because you are not explaining yourself well is not a winning strategy.
 
matt larkin
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well mr Bear I solved my own problem finally. and as you have shown me, this site contains only incompetant programmers who cant understand a simple scenario. stackOverflow.com is where I shall go from now on, thank you for confirming my friends opinion on your forum as being amateur
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

matt larkin wrote:well mr Bear I solved my own problem finally. and as you have shown me, this site contains only incompetant programmers who cant understand a simple scenario. stackOverflow.com is where I shall go from now on, thank you for confirming my friends opinion on your forum as being amateur



Seeing as how you got help from SO I don't see how you solved your own problem. Obviously, the folks at SO were able to mind read a bit more than we were. Sorry about that. As for the incompetent (not spelled incompetant btw) remark, you couldn't be further from the truth. Especially with regards to Bear. All we wanted was for you to explain yourself better. But if you're happier at SO then I wish you the best of luck.
 
reply
    Bookmark Topic Watch Topic
  • New Topic