Using Dart with HTML (things i could do in Javascript)


What I did in JS:

<script type="text/javascript">

function displayThesis(){
    var thesisForm = document.getElementById("thesisForm").innerHTML;
document.getElementById("activeForm").innerHTML = thesisForm;

function displayNonThesis(){
var nonThesisForm = document.getElementById("nonThesisForm").innerHTML;
document.getElementById("activeForm").innerHTML = nonThesisForm;

then later i would do something such as:

<form action="" method="get">
  <p>Do you need the thesis option form?</p>
  <input name="thesisOption" type="radio" value="Yes" onclick="displayThesis()" />
  <input name="thesisOption" type="radio" onclick="displayNonThesis()" />

to call those functions.

How would i do this with an external dart program that is listed and called with:

<script type="application/dart" src="attempt1.dart"></script>


It’s forbidden in Dart. Inline event listeners is bad idea anyway. It’s much better to separate HTML and script code. You can attach event listeners from dart code:

document.query('input[name="thesisOption"][value="Yes"]') (e) {
  document.query("#activeForm").innerHTML = document.query("#thesisForm").innerHTML;

Of source, you should add significant class names and ids to elements to refer to them clearly.

Answered By – Pavel Strakhov

Answer Checked By – Gilberto Lyons (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *