Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Use Value of Another Tag in Onclick Event

 
Steve Dyke
Ranch Hand
Posts: 1616
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an onclick event on an input tag. I want to use the value of another input tag as one of the parameters I am sending to the js function.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So get the value of the other input tag and send it to the JavaScript function.
 
Steve Dyke
Ranch Hand
Posts: 1616
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:So get the value of the other input tag and send it to the JavaScript function.


Thats what I want to do but I don't know how to reference the indirect(other) input tag's value as a parameter in the onclick attribute of direct(this) input tag.

I hope this makes sense, again I don't do a good job explaning somtimes.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you know how to get the value of another input element? What JS library are you using? It doesn't get a whole lot easier than this--you might want to brush up on some JavaScript/DOM fundamentals before proceeding much further, it'll make your life a lot easier.
 
Steve Dyke
Ranch Hand
Posts: 1616
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:Do you know how to get the value of another input element? What JS library are you using? It doesn't get a whole lot easier than this--you might want to brush up on some JavaScript/DOM fundamentals before proceeding much further, it'll make your life a lot easier.


I use jquery mostly. I know how to get the value of tag while I am in js. I was in the process in of a long explanation when I realized I was going the wrong direction with my whole approach. Sorry for the bother but I am sure I will have more questions to come. I am glad there is a place to go to when I run into problems.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, for the sake of those that follow: if you know how to get the value of an element when you're "in JS", what's the issue? The "onclick" handler attribute value *is* JavaScript, so you'd get the value of the input element and pass it to the onclick handler function. Again for the benefit of people that find this thread via a search for a similar question, it'd be nice if you posted the solution, even you end up going a different direction.
 
Steve Dyke
Ranch Hand
Posts: 1616
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:So, for the sake of those that follow: if you know how to get the value of an element when you're "in JS", what's the issue? The "onclick" handler attribute value *is* JavaScript, so you'd get the value of the input element and pass it to the onclick handler function. Again for the benefit of people that find this thread via a search for a similar question, it'd be nice if you posted the solution, even you end up going a different direction.


I on my page had a set of radio buttons and an input tag with an onclick attribute. When th input tag was clicked I was tring to send the value of the checked radio button as a prameter in the input tag onclick event. The onclick event displays a list based on the vale on the radio button set. My solution was to use the radio button onclick to get the list and use the select onclick to populate the input tag value.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I actually meant the value of the "onlick" attribute that uses the value of another input element.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic