Arc Forumnew | comments | leaders | submitlogin
3 points by thaddeus 4907 days ago | link | parent

Radio buttons need the 'checked' attribute to set the initial selection.

See: http://www.w3schools.com/tags/att_input_checked.asp

Mulitple radio buttons having the same name will act as a group.

See: http://www.w3schools.com/jsref/dom_obj_radio.asp

In arc, the requested attribute will reflect the currently selected radio button for the group.

Also, note that arc's gentag doesn't handle the 'checked' attribute. So you you'll need to add:

  (attribute input      checked        opstring)
into html.arc. Just put it in with the others.

Then change your code:

  (def radio (n v (o c nil))
    (gentag input type 'radio name n value v checked c))
Results:

  arc> (radio "rdgp" 1)
  <input type=radio name="rdgp" value="1">

  arc> (radio "rdgp" 2 "checked")
  <input type=radio name="rdgp" value="2" checked="checked">
Optionally, instead of extending attributes one at a time, you can write a more generic gentag macro to handle anything you throw at it. And I'm pretty sure if you did a Google search on the arc forum you might even find it's already done.