I have a button:     &lt;div id="save-submit" class="save-submit"&gt;             Submit Code         &lt;/div&gt;   When its clicked it checks for an input, if the input is correct i rename the button to continue:   $('.save-submit').click(function(e){   var button = document.getElementById("save-submit");                     button.className="next-task";                     button.innerHTML="Continue";                     button.id="next-task-id";    });   When the continue button is pressed it should load new tasks, but its going back to the save-submit aka trying to rename the button.   $('.next-task').on('click', function (e) {         e.preventDefault();         GetTask();  });   What am i doing wrong?  Thanks!
112
I have a bit of code where I am looping through all the select boxes on a page and binding a .hover event to them to do a bit of twiddling with their width on mouse on/off.  This happens on page ready and works just fine.  The problem I have is that any select boxes I add via Ajax or DOM after the initial loop won't have the event bound.  I have found this plugin (), but before I add another 5k to my pages with a plugin, I want to see if anyone knows a way to do this, either with jQuery directly or by another option.
73102
I am having problem while looping.  I am always getting an extra button. Please help.   {this.state.items.map(myitems1 =&gt; {     return (        &lt;div key={myitems1.Id}&gt;            &lt;span&gt;{myitems1.Item_x0020_Name}&lt;/span&gt;            &lt;button onClick={e =&gt; this.dosometing(myitems1.Id)}&gt;Offline&lt;/button&gt;        &lt;/div&gt;     ); })}   I can see the collection has only three (3) values, But I am getting 4 buttons on screen.   Getting always extra
61930
I'm reloading a web page that has the following code:  &lt;label for="showimage"&gt;Show Image&lt;/label&gt; &lt;input id="showimage" name="showimage" type="checkbox" value="1" /&gt;   Even though the HTML stays sent to the browser is the same for each reload of the page, the checkbox always takes on the checked value when a reload was performed.  In other words, if the user checks the checkbox and reloads, the checkbox is still checked.  Is there some caching going on here?    Edit: I tried Gordon Bell's solution below and find that this is still happening even after removing the value="1".  Anything else I might be missing?  &lt;label for="showimage"&gt;Show Image&lt;/label&gt;  &lt;input id="showimage" name="showimage" type="checkbox" /&gt;
48008
On some websites, when you hit the "Back" button, the browser attempts to go to the previous web page, but the current page opens up again. It happens even when the original page has finished loading. Hitting the "Back" button dozens of times doesn't prevent the behaviour, and I get "stuck" on that page.  What would explain this? It has happened to me on virtually every browser I've ever used.
9474
I have 3 buttons in a form. One of them is the submit button. How can I make it the default button to be clicked when I press the enter key. Is there a property for this?
42461
I am designing a site that has a variety of points in which I need to render "workflow" buttons that are used to send actions to an external application.   I used the form API to generate these buttons, and am using the #submit => option on my buttons to direct specific button types to custom functions. I am also using hidden fields to house data that I use to facilitate the action.   The problem I am having is that these buttons can and should show up multiple times per page, for different aspects of the application, and whenever I click one of the buttons Drupal attempts to submit all of the forms.   I guess what i am asking is, how can I have multiple instances of the exact same form on screen at any given time, and know with certainty that the submit buttons are only going to trigger actions for the specific instance of the form they belong to?  thanks in advance!!  Edit  So here is the crux of the problem - it appears that the getFormId needs to return a unique value, but I cannot figure out how to pass unique values into it.
26203
I'm trying to direct a browser to a different page. If I wanted a GET request, I might say  document.location.href = 'http://example.com/q=a';   But the resource I'm trying to access won't respond properly unless I use a POST request. If this were not dynamically generated, I might use the HTML  &lt;form action="http://example.com/" method="POST"&gt;   &lt;input type="hidden" name="q" value="a"&gt; &lt;/form&gt;   Then I would just submit the form from the DOM.  But really I would like JavaScript code that allows me to say  post_to_url('http://example.com/', {'q':'a'});   What's the best cross browser implementation?  Edit   I'm sorry I was not clear. I need a solution that changes the location of the browser, just like submitting a form. If this is possible with , it is not obvious. And this should not be asynchronous, nor use XML, so Ajax is not the answer.
932
Suppose I attach an blur function to an HTML input box like this:  &lt;input id="myInput" onblur="function() { ... }"&gt;&lt;/input&gt;   Is there a way to get the ID of the element which caused the blur event to fire (the element which was clicked) inside the function? How?  For example, suppose I have a span like this:  &lt;span id="mySpan"&gt;Hello World&lt;/span&gt;   If I click the span right after the input element has focus, the input element will lose its focus. How does the function know that it was mySpan that was clicked?  PS: If the onclick event of the span would occur before the onblur event of the input element my problem would be solved, because I could set some status value indicating a specific element had been clicked.  PPS: The background of this problem is that I want to trigger an AJAX autocompleter control externally (from a clickable element) to show its suggestions, without the suggestions disappearing immediately because of the blur event on the input element. So I want to check in the blur function if one specific element has been clicked, and if so, ignore the blur event.
80476
I have two function which needs to be called from one button. Currently I am doing this by creating two button one "Confirm" and another "Save". but I don't want two button I want only one button "Save", on click of Save first the method called by "Confirm" button should be called and then the method called by "Save" button.  Below is my code:  &lt;apex:commandButton value="Confirm" action="{!save}"/&gt;    &lt;apex:commandButton value="Save" action="javascript:top.window.opener.closeFunction()" &gt;&lt;/apex:commandbutton&gt;
88313
Usually, we only have 2 buttons at the bottom of a form or a page that requires an action: Submit &amp; Cancel.  This one is quite easy to style. However, what if we are dealing with multiple buttons at the bottom of a page? For example:   ← Back | Send Email | Booking Paid | Check-in Guest   I'm thinking of making "Back" just a link (not a button) and making "Send Email" / "Booking Paid" secondary buttons (light gray). Then I'd make "Check-in Guest" as the primary button (green).  I still feel that there's a better way of doing it or dealing with multiple buttons / actions. What do you think?
45710
I'm trying to test a page that has an input but really its a drop down list. The user enters text and then a dropdown appears based on what the user inputted. They are groups that are in the database. If I look for these elements before typing anything they dont exist but once I start typing they do exist.  The problem is I cant just type the whole name and then press enter or return because an option has to be selected from the list.  I can press arrow down to get the focus on the item from the list but then if I say enter it doesnt select, it sends that enter to the original element and nothing gets selected.  I can find the select element:  var ddList = driver.FindElement(By.CssSelector(".ui-autocomplete-input")); ddList.SendKeys("Admins");   This is the first time the list appears in the html.  It looks like this:  &lt;li class="ui-menu-item" role="presentation"&gt;
65851
Is there a well-supported, common behavior that I can expect if I do something like this in HTML:  &lt;form method="get" action="/somePage.html?param1=foo&amp;param2=foo"&gt;   &lt;input name="param2"&gt;&lt;/input&gt;   &lt;input name="param3"&gt;&lt;/input&gt; &lt;/form&gt;   Seems like this sort of thing is inherently ridiculous, but I've seen it used here and there and I was wondering what on Earth the expected behavior should be.  Are browsers smart enough to tack on "&amp;param2=whatever&amp;param3=whatever" to the action, or do they just throw in a second question mark?  Or what?  Are there cases where this is actually the right way to do things?
8344
I'm working with a bit of html and Javascript code that I've taken over from someone else. The page reloads a table of data (via an asynchronous request) every ten seconds, and then re-builds the table using some DOM code. The code in question looks something like this:  var blah = xmlres.getElementsByTagName('blah'); for(var i = 0; i &lt; blah.length; i++) {     var td = document.createElement('td');     var select = document.createElement('select');     select.setAttribute("...", "...");     select.onchange = function() {         onStatusChanged(select, callid, anotherid);     };     td.appendChild(select); }   When the onchange event is fired for a &lt;select&gt; element however, it seems like the same values are being passed to the onStatusChanged() method for every &lt;select&gt; in the table (I've verified that in each iteration of the loop, callid and anotherid are being given new, distinct values).   I suspect this is occuring because of the nature of how I am setting the event handler, with the select.onchange = function() syntax. If I understand how this is working correctly, this syntax sets a closure for the onchange event to be a function which refers to these two references, which end up having a final value of whatever they are set to on the last iteration of the loop. When the event fires, the value referenced by callid and anotherid is the value set in the last iteration, not the value set at the individual iteration.  Is there a way that I can copy the value of the parameters I am passing to onStatusChanged()?  I've changed the title to better reflect the question and the accepted answer.
54687
The  documentation provides this example:  &lt;aura:component&gt;     &lt;lightning:recordEditForm recordId="003XXXXXXXXXXXXXXX" objectApiName="Contact"&gt;         &lt;lightning:messages /&gt;         &lt;lightning:inputField fieldName="FirstName" /&gt;         &lt;lightning:inputField fieldName="LastName" /&gt;         &lt;lightning:inputField fieldName="Email" /&gt;         &lt;lightning:button class="slds-m-top_small" variant="brand" type="submit" name="update" label="Update" /&gt;     &lt;/lightning:recordEditForm&gt; &lt;/aura:component&gt;   where a a click on the nested submit button causes the data to be saved.  Anyone know of a reliable/documented way to get the lightning:recordEditForm to save based on a click of a button located elsewhere in the page?
102672
When a question received close votes for being a duplicate and one also casts a close vote for that reason, previously suggested duplicates can be selected.  That's convenient. The preview of the duplicate is expanded to show the entire question and all answers, which helps reviewing this possible duplicate.  The big amount of additionally displayed content pushes the submit button very far down. It's often sufficient to read the other question or a few answers to decide if it is indeed a duplicate.  All the convenience of being able to click on a previous suggestion is eliminated by the need to scroll all the way down to the bottom of the pop-up in order to click on the submit button.  Some possible solutions I could think of:   position the button near the top create multiple buttons and place one below the question and every answer move the button along when scrolling the window keep the height of the popup constant and let the content of the question expand in its own scrollable environment
90856
Ok, I'm doing a bunch of RIA/AJAX stuff and need to create a "pretty", custom confirm box which is a DIV (not the built-in javascript confirm). I'm having trouble determining how to accomplish a pause in execution to give the user a chance to accept or decline the condition before either resuming or halting execution. (depending upon their answer)   So here's the general flow of logic I'm dealing with:   User selects an item from dropdown and clicks button. In client-side javascript eventhandler for button, I need to check a (this is the key) SERIES of conditions for the item they chose in dropdown.  These conditions could possibly result in not showing any confirmation at all or possibly only some of the conditions may evaluate to true which means I'll need to ask the user to accept or decline the condition before proceeding. Only one confirmation should be show at a time.   To demonstrate the logic:  function buttonEventHandler() {  if (condition1) {   if(!showConfirmForCondition1) // want execution to pause while waiting for user response.      return; // discontinue execution }  if (condition2) {   if (!showConfirmForCondition2) // want execution to pause while waiting for user response.       return; // discontinue execution }  if (condition3) {   if (!showConfirmForCondition3) // want execution to pause while waiting for user response.       return; // discontinue execution }  ...   }    If anybody has dealt with this challenge before and found a solution, help would be greatly appreciated. As a note, I'm also using the MS Ajax and jQuery libraries although I haven't found any functionality that may already be included in those for this problem.
115970
Using a ajax request I want to change content of my div.  &lt;div id="d1"&gt;202&lt;/div&gt;   So I want to change the content to a different number.  $('d1').InnerText???   Also, say I wanted to increment the number, how could I do that? Do I have to convert to int?