How to manipulate data in HTML?

Asked

Viewed 96 times

0

I’m thinking of a scheme, but I don’t know how to do it, and it’s simple. I need to make the following calculation:

Day and Month x Month and Day, example, date today:

Dia: 16
Mês: 07
x (vezes)
Mês: 07
Dia: 16

On a calculator it will look like this: 1607*716 = 1150612

Just this, do this calculation always with the current date that is on the machine and display the result value.

How to do this in HTML?

  • 2

    No, HTML is just a markup language. You will need to use Javascript.

  • Okay, but do you have a script that does that that I can include?

2 answers

1

Only with HTML will not scroll you manipulate data this way.

What you can do is a very simple script:

<script>
  var atual = new Date();
  var dia = atual.getDate().toString();
  var mes = (atual.getMonth() + 1).toString();

  document.write(parseInt(dia+mes) * parseInt(mes+dia));
</script>

That should work.

I hope I’ve helped.

Hugs.

1

With Javascript you can do it as follows:

var date = new Date();
var day = '' + date.getDate();
var month = '' + (date.getMonth() + 1);

day = day.length == 1 ? '0' + day : day;
month = month.length == 1 ? '0' + month : month;

var result = parseInt(day + month) * parseInt(month + day);
  • Man, it worked right!!!

  • Thanks a lot! It was perfect

Browser other questions tagged

You are not signed in. Login or sign up in order to post.