Solved

Javascript: Find and Enable Submit Button in Table

Posted on 2016-11-16
3
80 Views
Last Modified: 2016-11-17
I have a dynamically created table. Each row of the table includes form elements. It includes a drop down and a submit button.
The submit button is disabled by default and I want in enabled when I change the drop down.
The following function works great in making changes and calculation on the other data in the row, but I can't seem to get the SubmitButton to enable. Can someone tell me what I'm doing wrong?

// Chnages Op on rank change
	$(".rank").change(function() {
    var $rankop = this.value; // get Rank value
    var $catrow = $(this).closest("tr");    // Find the row
    var $catop1 = $catrow.find(".catop").text(); // Find cat Op
	var $baseop = $catrow.find(".baseop").val(); // Find baseop
	var $catop = ($rankop * $baseop); // Multiply ranking x op for new op 
	    $catop =$catop.toFixed(2);    // format to 2 decimal points
		
	$catrow.find(".rankop").val($rankop); // change value of hidden field calcop for form submit
	$catrow.find(".calcop").val($catop); // change value of hidden field calcop for form submit
	$catrow.find(".catop").text($catop); // change text of catop cell to new op
	$catrow.find(".SubmitButton").disabled = false; // Enable Submit Button. This is part that does not work

});	

Open in new window

0
Comment
Question by:dannyg280
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 57

Accepted Solution

by:
Julian Hansen earned 500 total points
ID: 41889621
If youre table is dynamic - do you mean in the browser or in how it is rendered on the server?

You may be running into the problem of binding to the row before it is created. Try changing this (Line 2)
$(".rank").change(function() {

Open in new window

To this
$('body').on('change', '.rank', function() {

Open in new window

With the above change - even if you add rows to the table in the browser the change event will fire.
0
 
LVL 57

Expert Comment

by:Julian Hansen
ID: 41889623
Also change your line 13 to this

$catrow.find(".SubmitButton").prop({disabled: false});

Open in new window


Use the prop() method
0
 

Author Closing Comment

by:dannyg280
ID: 41891603
Perfect. Thank you
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Help with mod_substitute 18 72
send html form with multipe immages as buttons 2 34
javascript duplicates 9 21
Presenting my portfolio on the web? 11 49
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question