1

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;
}
</script>

then later i would do something such as:

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

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>

1 Answer 1

4

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"]').on.click.add( (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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, but I am not sure how exactly to implement this. I can just leave this in my Main() and then how do i make it document.query("#activeForm").innerHTML = thesisForm; ?
Fixed my comment. But I'm not sure because I don't know dart syntax well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.