.innerHTML=
may not be the correct JS method. Prefer .value=
or innerText=
.
But even better would be to use %{}
parameter replacement to stuff the values into the HTML file before you send it to the dialog.
Rememeber this example topic ?
You do similar with HTML text in Ruby:
# form_data is a hash of values for the HTML form
# (you can use another reference name if you like)
# Load the HTML template file into a string:
html = File.read(File.join(__dir__,"my_dialog.html"))
# Replace the %{} parameters in the HTML with data from the hash:
@dlg.set_html( html % form_data )
# Set other dialog options and show it:
@dlg.show
So you load an HTML file into a html
string object.
This file is setup as a template with %{fieldname}
parameters that match the keynames of your Ruby value hash.
IE in the HTML template file …
<input type="text" id="wPlus_width" name="Width" value='%{width}'>
… And in Ruby you load up a hash of values like …
form_data = {
width: wPlus_width.to_s # Assume this is a SketchUp Length object
# other data fields
}
Now the call to html % form_data
would replace the %{width}
substring in the HTML file string with the value marked with the :width
key from the hash.
As Julia said, if you are using Length
objects on the Ruby side, it’s class’ #to_s
method will automagically use the correct decimal delimiter for the numeric string in the form_data
hash.
When the string is sent back to Ruby, SketchUp’s String#to_l
method automagically knows what the decimal separator is.
ADD: I also explained the above %{}
replacement concept here …
… and (further down that topic) …