Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Radio set to Checked upon page load - How?

Status
Not open for further replies.

RP1America

Technical User
Aug 17, 2009
221
US
Hi!

I have two radio buttons within a form and would like to have the first already checked when the page loads. I have been researching and have come across many (seemingly) incorrect solutions - checked; checked="yes"; checked="true"; checked="checked" - which none work for me.

Given the following code, how can I make the "Subscribe" radio button automatically checked when the webpage loads?

Code:
<div style="position: absolute; left: 3px; top: 110px; border:1px solid #999999; width:230px; margin: 0px; background-color:#F2F4FA;"><form method="post" action="[URL unfurl="true"]http://pub15.bravenet.com/elist/add.php"[/URL] style="margin:0px;">
<div style="background-color:#DBE0F5; padding:3px; font:12px arial; color:#000000;"><b>Join the Periphonic Mailing List</b></div>
<div style="margin:10px; font: 11px arial; color: #000000; text-align:left;">
<div style="margin-bottom:5px;">Enter your name and email address below for Periphonic news, contests, and more:</div>
<div style="text-align:right;">Name: <input name="ename" size="25" maxlength="60" style="width: 170px" id="elistname" /><br />Email: <input name="emailaddress" size="25" maxlength="100" style="width: 170px" id="elistaddress146218231" /><br /><span style="white-space:nowrap;"><input name="action" value="join" type="radio" style="border: 0px;" />Subscribe </span><span style="white-space:nowrap;"><input name="action" value="leave" type="radio" style="border: 0px;" />Unsubscribe </span><input name="usernum" value="1283553571" type="hidden" style="border: 0px solid black; height: 0px; width: 0px;" /><input name="cpv" value="1" type="hidden" style="border: 0px solid black; height: 0px; width: 0px;" /> <input name="submit" value="GO" type="submit" /></div>
</div>
<div style="color: red" id="elist_err146218231"></div>
</form></div>

site is
Thanks!
 
Your [tt][blue]checked="checked"[/blue][/tt] was the right solution. Maybe you applied it incorrectly.
Code:
<input name="action" value="join" type="radio" style="border: 0px;" checked="checked" />

[small]Do something about world cancer today: Comprehensive cancer control information at PACT[/small]
 
Thanks for the reply, Vragabond.

I tried it again and unfortunately, it is still not working for me. The only thing I can assume is that it has something to do with my hosting account. When editing my html document, it does not allow (what it thinks is) incorrect language. As in, if I forget to close a tag, it will close it for me, etc. Perhaps somewhere in the logic it is not accepting 'checked' as an attribute.

Are there any other ways to accomplish this? Perhaps something else may work.

Thanks!
 
Better yet...what code could I remove/change in order for the radio buttons to completely go away...so that when you click "GO", it is the same as selecting the "Subscribe" radio button and clicking "GO".
 
As in, I have no need for an Unsubscribe selection.
 
...it is still not working for me. The only thing I can assume is that it has something to do with my hosting account...
Your hosting account shouldn't enter into it - if [tt]checked="checked"[/tt] is the HTML you're sending out, then it should work. Do a "View Source" on your page when you look at it in a browser to see the HTML you're actually sending, as opposed (perhaps) to what you think you're sending.

Oh, and you'll find your code a lot easier to debug and maintain if you break it up with a few spaces and line feeds. Try using HTML Tidy ( ) if you don't want to do it manually.

what code could I remove/change in order for the radio buttons to completely go away

Ideally, you'd change the server-side code not to require this parameter. But it looks like the script is owned by a third party, so you need to put this instead of the radio button inputs:
Code:
<input type="hidden" name="action" value="join" />



-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
try this

<input name="action" value="join" type="radio" style="border: 0px;" checked />
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top