1

I need write static web page with simple data. In form i have data from user and in tag <div id="prog"> my output How using Opal writing string into specyfic place?

<div id="prog">
</div><script type="text/javascript">
<div id="prog">
</div>
</script>
pp = document.getElementById("prog").innerHTML = Opal.main()
</script>
last10seconds
  • 333
  • 1
  • 3
  • 18
Powoli
  • 23
  • 5

1 Answers1

1

Ok, so based on your sample code, you just need to make Opal.main() return a string

def main
  # logic
  return str
end

But I think that what you really want is use opal-jquery or opal-browser, I don't have much experience with the later, so here's a simple example of opal-jquery (of what I understood you were asking)

Document.ready? 
  Element["form"].on(:submit) do
    Element["#prog].text = Element["#input-id"].value
  end
end
gabrielrios
  • 554
  • 1
  • 4
  • 12