Change commas for points in a spinner

0

I am making a web application and I would like the decimal data to appear with period or with commas, but being the coherent application in all since the data in the database appear with points and in the spinner with commas. I would like to know how I can make everything appear the same either by changing the configuration of the spinner or the database (Mysql).

<label id="stockL" for="stock"> Peso por unidad: </label>
<input type="number" id="stock" name="stock" value="<?php echo $Peso ?>" 
class="form-control" step="0.25" style="width:100px" min="0" value="0" required/>
    
asked by adamista 27.01.2016 в 23:22
source

2 answers

1

Well what I understand is that you want to present the spinner with a dot instead of a comma, so it is not advisable to change the database, if you want to change the presentation of the spinner you can use jquery to present the spinner in the way that you wish, you could do something like this:

<html>
<head>
  <meta charset="utf-8">
  <title>Decimal Spinner</title>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
  <script>
  $(function() {
    $( "#spinner" ).spinner({
      step: 0.25,
      numberFormat: "n"
    });
  });
  </script>
</head>
<body>
 
<p>
  <label for="spinner">Decimal spinner:</label>
  <input id="spinner" name="spinner" value="0">
</p>
 
</body>
</html>
    
answered by 28.01.2016 в 05:53
0

It is not an answer but it is too long for comment.

  

the data in the database appears with points

This suggests a deep confusion, which matters to clarify. We are talking, I suppose, of numerical data with a decimal point [*]. Now, what does that mean that "in the database appear with points"?

The first thing you should clarify (te) is: how is the data stored in the DB? As a string (string of characters = text) or as a numeric type (DECIMAL, NUMERIC, REAL, etc)?

If the first thing, we are in design problems. The DB must use the "correct" data type.

If the second, then it's fine, but your concern that "appears the same on the db" that on the website does not make much sense. What "appears in the DB" is simply what your application shows you are using to view the DB (eg, a desktop client such as MySQL Workbench, or a web client such as PhpMyAdmin). It is fine that the "locale" of that application according to your preference, but that has NOTHING to do with your web page.

[*] Note: a credit card number, for example, or a telephone number or a postal code, are not strictly numeric data; they are only texts, whose characters are restricted to decimal digits. The numerical data are those that, for example, it makes sense to add and subtract.

    
answered by 27.02.2016 в 16:57