HtmlDialog. User's system expects a comma delimiter. Number.to_l throws an error

I’ve rewritten some code from An example … to implement Dan’s suggestions. It works when I change the type of length, breadth and depth in the html form from number to text. If I leave the type as number the html won’t show the locale numbers with their comma decimal separator. The fields in the HtmlDialog form show as blank fields. I guess this is a fundamental of html that it only recognises points as decimal separators and so I must ‘type’ floating point numbers as ‘text’. When I change the type to text the HtmlDialog form fields show the locale numbers correctly and the data is correctly interpreted on the Ruby side and I get a box modeled in my SketchUp model.

The code below doesn’t work -

<form>
	length: <input id='id1' type='number' name='length' value='%{length}' required><br>
	breadth: <input id='id2' type='number' name='breadth' value='%{breadth}' required><br>
	depth: <input id='id3' type='number' name='depth' value='%{depth}' required>
</form>

but this does work

<form>
	length: <input id='id1' type='text' name='length' value='%{length}' required><br>
	breadth: <input id='id2' type='text' name='breadth' value='%{breadth}' required><br>
	depth: <input id='id3' type='text' name='depth' value='%{depth}' required>
</form>

The only drawback is that the user loses the incremental arrows on the right hand side of the input field.

I could post the entire example if the forum thought it would be useful. Just let me know.

Thank you to every one who helped with this. Cultures and their diversity make programming interesting.

1 Like