user2155012
user2155012

Reputation: 1

Query string to pre-select radio button

Generally when i have used query strings in the past i have easily parsed variables so that the input value is shown in the form when the page loads.

E.G. [email protected] - which would pre-populated the email input. But i am not sure how to use for radio buttons.

E.G. say if i have a yes (id = rsvp_0) and a no (id= rsvp_1) radio button. I have tried to parse [email protected]&rsvp_0=checked with no luck. I have also tried yes, 1 and all other variations.

Assistance appreciated

PS - here is a working example to test with: http://storage.coremotivesmarketing.com/library/dff93ae6-e2b5-4b50-abd9-3b539016a95b/707/webforms/d9d2c17b-c42b-e311-8aea-000c299b63b3.htm?txtEmailAddress=c@c.com.au&rsvp_0=checked

Regards, Chris

Upvotes: 0

Views: 3334

Answers (1)

Tory
Tory

Reputation: 477

I was just looking for this same answer, and I just figured it out, it is actually very possible, with checkboxes and radios, instead of having the query string be "id=value", you actually have "name=inputvalue", so, let's say you have this:

<form>
    <label for="rsvpYes">Yes</label>
    <input name="rsvp" id="rsvpYes" value="yes" />
    <label for="rsvpNo">No</label>
    <input name="rsvp" id="rsvpNo" value="no" />
</form>

The query string to select the "no" radio would be this:

?rsvp=no

And to select the "yes" radio it would be this:

?rsvp=yes

Upvotes: 1

Related Questions