Question

Background

I'm making some changes to an existing custom BSP page in order to improve usability on Windows RT tablets.

I've been asked to change an input field (currently type="text") so that the number pad comes up when someone starts typing a value, in stead of the full keyboard. This is easily achieved by changing the input field type to type="number"

My Problem

After refreshing the page, (due to sorting, backing out from the next page etc). The integer field used as the value in the input field is coming back with an extra space attached to it:

My Code

data: lv_qty type i value 3.

<tr>
  <td><%=lv_field1%></td>
  <td><%=lv_fieldn%></td>
  <td>|<%=lv_qty>|</td>
</tr>

Generated HTML:

<tr>
  <td>Value1 </td>
  <td>Value2 </td>
  <td>
    |3 |  <!-- Note the extra space here! -->
  </td>
</tr>

So I'm always getting the extra space; but it only causes a problem when trying to use it with <input type="number">

It is possible that BSP have not really been updated for HTML 5 and that I'm just stuck with this problem, but is there anything I can do on the server side to prevent this?

Client-side I'm considering using JavaScript to trim off the extra space, but it seems like an unnecessary workaround.

EDIT

Ok in trying to simplify the code for the question, I actually obfuscated the problem:

My real problem occurs when I'm trying to use lv_qty as an input field of type="number" and then refresh the page for whatever reason.

The code in this case is as follows:

data: lv_qty type i.

<tr>
  <td><%=lv_field1%></td>
  <td><%=lv_fieldn%></td>
  <td>
    <input type="number" value="<%=lv_qty%>">
  </td>
</tr>

This is still simplified, but the problem becomes fairly obvious: (I put the value lv_qty in double-quotes).

I still think that the extra space that I get from the server side shouldn't be there, but the fix is pretty simple: Don't be an idiot and pass numbers back to the webpage as numbers, not strings :).

Était-ce utile?

La solution 2

Remove the double-quotes around the integer value:

data: lv_qty type i.

<tr>
  <td><%=lv_field1%></td>
  <td><%=lv_fieldn%></td>
  <td>
    <input type="number" value=<%=lv_qty%> >  <!--No double quotes here-->
  </td>
</tr>

Autres conseils

Try to use a string template with condense:

<td>|<%=|{ condense( lv_qty ) }|>|</td>

Since you are using a Z BSP, why not define lv_qty as a page attribute type string?

Then your display should be just the number.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top