Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 538 Vote(s) - 3.52 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Add/Subtract Click Function

#1
Can anyone modify this code to [Add by left clicking the number], and [Subtract by right clicking the number]?

This would get rid of the + and - buttons.

I can't figure out how to do it.

**[DEMO][1]**

**HTML**

<input id="txtNumber" type=text" value="55" style="width:30px" />
<input id="btnAdd" type="button" value="+" onclick="add();" />
<input id="btnSubtract" type="button" value="-" onclick="subtract();" />

**Javascript**

function add()
{
var txtNumber = document.getElementById("txtNumber");
var newNumber = parseInt(txtNumber.value) + 1;
txtNumber.value = newNumber;
}

function subtract()
{
var txtNumber = document.getElementById("txtNumber");
var newNumber = parseInt(txtNumber.value) - 1;
txtNumber.value = newNumber;
}


[1]:

[To see links please register here]

Reply

#2
This is a good way to do it:

[To see links please register here]


**HTML**

<input id="txtNumber" type=text" value="55"
style="width:30px" onclick="javascript:add()"
oncontextmenu="javascript:subtract(event)" />

**Javascript**

function add()
{
var txtNumber = document.getElementById("txtNumber");
var newNumber = parseInt(txtNumber.value) + 1;
txtNumber.value = newNumber;
}

function subtract(e)
{
e.preventDefault();
var txtNumber = document.getElementById("txtNumber");
var newNumber = parseInt(txtNumber.value) - 1;
txtNumber.value = newNumber;
return false;
}

If you just set `add()` to run on click and `subtract()` to run on right click (when the context menu would come up), you can capture the click types you want. Then just pass in `event` to `subtract()` and stop it from doing what it would normally do, i.e. bring up the context menu.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through