Saturday, April 1, 2023
Learning Code
  • Home
  • JavaScript
  • Java
  • Python
  • Swift
  • C++
  • C#
No Result
View All Result
  • Home
  • JavaScript
  • Java
  • Python
  • Swift
  • C++
  • C#
No Result
View All Result
Learning Code
No Result
View All Result
Home JavaScript

Html form tag that blocks a click counter button – JavaScript – SitePoint Forums

learningcode_x1mckf by learningcode_x1mckf
November 21, 2022
in JavaScript
0
Time limit for notify – JavaScript – SitePoint Forums
74
SHARES
1.2k
VIEWS
Share on FacebookShare on Twitter


You might also like

4 Packages for Working With Date and Time in JavaScript – MUO – MakeUseOf

Understanding the Power of Proxy in JavaScript – hackernoon.com

JavaScript vs. TypeScript: What's the difference? – TheServerSide.com

On my chrome extension I attempt to create a click on counter with a reset button however I’ve slightly drawback, the 2 buttons are in an html type tag which blocks them however once I put the 2 buttons outdoors the Kind tag it really works, my query is there a solution to put the 2 buttons within the type tag with out them being blocked?

right here is the content material of my popup.html

<!doctype html>
<html>
    <head>
<meta charset="UTF-8">
<hyperlink rel="stylesheet" kind="textual content/css" href="https://information.google.com/__i/rss/rd/articles/model.css" media="display">
</head>
<physique>
<heart>
<div class="field">
<type identify="myForm" id="myForm">
<h2> Please enter a code </h2>
 <button id="btn" title="Entrée"></button> 
 <button id="reset-button" title="Actualiser">&#11118;</button> 
<enter identify="inpt" id="inpt" maxlength="10" autocomplete="off"/>
<h3 id="counter-label" title="Nombre de ticket créer">0</h3>

</type>
<!-- <button id="btn" title="Entrée"></button> -->
<!--   <button id="reset-button" title="Actualiser">&#11118;</button> -->
</div>
</heart>
</physique>
<script src="popup.js"></script>
</html>

And right here is the content material of my popup.js

window.addEventListener('DOMContentLoaded', setUpStuff, false);
perform setUpStuff(){
doc.getElementById("inpt").focus();
    let optionsButton = doc.getElementById('btn');
    optionsButton.addEventListener('click on', perform() 
var empt = doc.myForm.inpt.worth;
if (empt === "")

//coller
doc.execCommand("paste");
                 navigator.clipboard.readText()
      .then(txt => 
      doc.getElementById("inpt").worth = txt;
     )
chrome.tabs.question(lively: true, currentWindow: true, perform(tabs) 
            chrome.tabs.sendMessage(tabs[0].id, functionnum: doc.getElementById("inpt").worth.toUpperCase());

  );
return false;

else

//sans coller
 chrome.tabs.question(lively: true, currentWindow: true, perform(tabs) 
            chrome.tabs.sendMessage(tabs[0].id, functionnum: doc.getElementById("inpt").worth.toUpperCase());
        );
return true;

       
);
}

//counter+reset
doc.addEventListener('DOMContentLoaded', perform() 
var clickbtn = doc.getElementById('btn');
var resetBtn = doc.getElementById('reset-button');
var x=0
clickbtn.addEventListener("click on", perform onClick() 
let counter = doc.getElementById('counter-label');
x = x+1;
doc.getElementById('counter-label').innerHTML = x;
);
resetBtn.addEventListener("click on", perform onClick() 
x=0 ;
doc.getElementById('counter-label').innerHTML = x;
);

);

Hello,

I nonetheless had the code from the earlier extension, so I assumed I’d give this a go. Sadly, the code you posted above doesn’t let me recreate your drawback.

If I needed to guess, I’d say that buttons inside type tags have a tendency to submit the shape (their kind defaults to submit), in order that could possibly be inflicting you issues. Strive giving the buttons a sort of “button” and see if that helps:

<button kind="button" id="btn" title="Entrée">Entrée</button>

Hello,

when i add kind=“button” to button id=“btn” and I click on on enter nothing occurs the counter is just not blocked however the enter button doesn’t work on this case

Okay. Are you able to then please add sufficient code that I can reproduce your drawback and let me know which website I can take a look at it towards (if that’s necessary).

1 Like

That you just say that it really works when the buttons are situated outdoors the shape tag exhibits that the js code is working and that it’s in all probability working earlier than the DOM is absolutely created.
My resolution can be to incorporate a “defer” attribute within the “script” tag.
I’d additionally relocate the script tag as a toddler of the “head” tag.

1 Like

Thanks very a lot, lastly I used to be in a position to resolve the issue



Source link

Share30Tweet19
learningcode_x1mckf

learningcode_x1mckf

Recommended For You

4 Packages for Working With Date and Time in JavaScript – MUO – MakeUseOf

by learningcode_x1mckf
April 1, 2023
0
Google expands open source bounties, will soon support Javascript fuzzing too – ZDNet

4 Packages for Working With Date and Time in JavaScript  MUO - MakeUseOf Source link

Read more

Understanding the Power of Proxy in JavaScript – hackernoon.com

by learningcode_x1mckf
April 1, 2023
0
Google expands open source bounties, will soon support Javascript fuzzing too – ZDNet

Understanding the Power of Proxy in JavaScript  hackernoon.com Source link

Read more

JavaScript vs. TypeScript: What's the difference? – TheServerSide.com

by learningcode_x1mckf
April 1, 2023
0
Google expands open source bounties, will soon support Javascript fuzzing too – ZDNet

JavaScript vs. TypeScript: What's the difference?  TheServerSide.com Source link

Read more

JetBrains updates IDEs for Java, JavaScript, Ruby – InfoWorld

by learningcode_x1mckf
March 31, 2023
0
Google expands open source bounties, will soon support Javascript fuzzing too – ZDNet

JetBrains updates IDEs for Java, JavaScript, Ruby  InfoWorld Source link

Read more

Virtru Announces First Ever FIPS 140-2 Validated JavaScript … – GlobeNewswire

by learningcode_x1mckf
March 30, 2023
0
Google expands open source bounties, will soon support Javascript fuzzing too – ZDNet

Virtru Announces First Ever FIPS 140-2 Validated JavaScript ...  GlobeNewswire Source link

Read more
Next Post
JDK 20: What’s next for Java?

JDK 20: What’s next for Java?

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Related News

C can be memory-safe – Security Boulevard

C can be memory-safe – Security Boulevard

February 1, 2023
How to Use Stacks in Java

How to Use Stacks in Java

September 16, 2022
How to Convert a Number to a String in JavaScript

Quick Tip: How to Convert a Number to a String in JavaScript

October 21, 2022

Browse by Category

  • C#
  • C++
  • Java
  • JavaScript
  • Python
  • Swift

RECENT POSTS

  • So why did they decide to call it Java? – InfoWorld
  • Senior Java Developer – IT-Online
  • 4 Packages for Working With Date and Time in JavaScript – MUO – MakeUseOf

CATEGORIES

  • C#
  • C++
  • Java
  • JavaScript
  • Python
  • Swift

© 2022 Copyright Learning Code

No Result
View All Result
  • Home
  • JavaScript
  • Java
  • Python
  • Swift
  • C++
  • C#

© 2022 Copyright Learning Code

Are you sure want to unlock this post?
Unlock left : 0
Are you sure want to cancel subscription?