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.
> 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.