1

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 :).

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Esti
  • 3,677
  • 8
  • 35
  • 57
  • Just a shot in the dark here, but I suspect the space being the sign. Don't know how to get rid of it in your BSP though... – Gert Beukema Oct 31 '13 at 23:39
  • @Gert Beukema not a bad guess; but I get the same behaviour with unsigned (String/CHAR/NUMC) fields. Those just doesn't cause problems on the HTML side. Interestingly - I never get the extra space when the variables are being passed back to the server, so there must be something on the server side that handles it. Got a feeling I may be stuck with this behaviour. – Esti Oct 31 '13 at 23:46

3 Answers3

2

Try to use a string template with condense:

<td>|<%=|{ condense( lv_qty ) }|>|</td>
tomdemuyt
  • 4,572
  • 2
  • 31
  • 60
  • +1 I didn't think it will work, but I decided to try it anyway. This caused me to pause and think "WTF are these double quotes doing here" which of course solved my problem - thanks for your input. – Esti Nov 03 '13 at 21:51
1

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>
Esti
  • 3,677
  • 8
  • 35
  • 57
0

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.