Skip to content

Comment on Ask HN: Difficult Form Problemparent

Comments

Yes

So you add an extra radio button at the bottom of the form, with an <input type=text> instead of a <label>. You will want some javascript to select the bottom radio button when the text control receives focus.

Then on the backend, if the extra radio button was selected, instead of incrementing the vote count for that answer, you create a new answer in the database with a vote count of 1.

I assume you have your answers stored in a table like the following (pseudo-sql, my sql is rusty):

  CREATE TABLE answers (
    question_id          INTEGER NOT NULL,
    answer_id            INTEGER NOT NULL,
    answer_total_votes   INTEGER DEFAULT 1,
    answer_text          TEXT NOT NULL,
    PRIMARY KEY (question_id, answer_id)
  )
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.