Hi
I need help to automatically select an option to submit with a form: When the 'form-email' field is blank i want it to select 'option 1' and, When the field is not blank i want it to select 'option 2'.
Here's my form code
<form method="post" onsubmit="return validate-category(this)" action="tdomf-form-post.php" id='tdomf_form1' name='tdomf_form1' class='tdomf_form'>
<textarea title="Post Title" name="content-title-tf" id="form-content" >Say it...</textarea>
<input type="text" value="" name="content-text-ta" id="form-email"/>
<select name='categories' class='form-category' type="hidden">
<option value="3" type="hidden">Anonymous</option>
<option value="4" type="hidden" selected="selected">Competition</option>
</select>
<input type="submit" value="Say it!" name="tdomf_form1_send" id="form-submit"/>
</form>
I have an idea that the javascript would go something like this, but can't find what the code is to change the value.
<script type="text/javascript">
function validate-category(field)
{
with (field)
{
if (value==null||value=="")
{
select category 1
}
else
{
select category 2
return true;
}
}
}
</script>
Any help on this would be great.
Thanks in advance.