Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / JavaScript / September 2006



Tip: Looking for answers? Try searching our database.

how to select a radio button on load??

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
admin@binindex.net - 29 Sep 2006 21:38 GMT
I have a page that has a form named search.  On page load I would like
to have the radio button for the category they are searching in to be
selected.  How can I do this everything I ahve tried keeps saying
object expected.
web.dev - 29 Sep 2006 22:05 GMT
> I have a page that has a form named search.  On page load I would like
> to have the radio button for the category they are searching in to be
> selected.  How can I do this everything I ahve tried keeps saying
> object expected.

Here's an example which automatically selects the first radio button.

javascript:

function autoForm()
{
    var myForm = document.forms["search"];

    myForm.elements["category"][0].checked = true;
}

window.onload = autoForm;

html:

<form name = "search">
<input type = "radio" name = "category"/>category 1
<input type = "radio" name = "category"/>category 2
</form>

Obviously, you'll have to implement the logic on which radio button is
to be selected.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.