I want to use the advanced search form for a job board and populate the categories from one channel only. I do not want to use the select option from an array of channels. I want to have one channel already selected. How would I change the code so that the user does not need to SELECT a channel in order to populate the categories field? I know it’s a simple change, but am having trouble.
I am using the newest version of EE.
Following is the code that is generated. I want to hide the channel option completely and have the category field populated with the categories associated with the channel. If the user adds or changes the categories, this would then be reflected in the form.
Here is the current code.
<form id="searchform" method="post" action="http://test.www.drbobnelson.com/" >
<div class='hiddenFields'>
<input type="hidden" name="ACT" value="6" />
<input type="hidden" name="XID" value="6de547148aac465917f1ca0dc1d96df72f16434f" />
<input type="hidden" name="RES" value="" />
<input type="hidden" name="meta"
value="YTo4OntzOjY6InN0YXR1cyI7czowOiIiO3M6NzoiY2hhbm5lbCI7czo2OiJwaG90b3MiO3M6OToic2VhcmNoX2luIj
tzOjA6IiI7czo1OiJ3aGVyZSI7czozOiJhbGwiO3M6MTI6InNob3dfZXhwaXJlZCI7czowOiIiO3M6MTk6InNob3dfZnV0dXJ
lX2VudHJpZXMiO2I6MDtzOjExOiJyZXN1bHRfcGFnZSI7czoyMToic2VhcmNoL3NlYXJjaF9yZXN1bHRzIjtzOjE1OiJub19y
ZXN1bHRzX3BhZ2UiO3M6MTc6InNlYXJjaC9ub19yZXN1bHRzIjt9ZmNiZDU4MTY3Nzk4YTA1NjYxMGJkNTI0MGM1NmMxNjE="
/>
<input type="hidden" name="site_id" value="1" />
</div>
[removed]
//<![CDATA[
var firstcategory = 1;
var firststatus = 1;
function changemenu(index)
{
var categories = new Array();
var i = firstcategory;
var j = firststatus;
var theSearchForm = false
if (document.searchform)
{
theSearchForm = document.searchform;
}
else if (document.getElementById('searchform'))
{
theSearchForm = document.getElementById('searchform');
}
if (theSearchForm.elements['channel_id'])
{
var channel_obj = theSearchForm.elements['channel_id'];
}
else
{
var channel_obj = theSearchForm.elements['channel_id[]'];
}
var channels = channel_obj.options[index].value;
var reset = 0;
for (var g = 0; g < channel_obj.options.length; g++)
{
if (channel_obj.options[g].value != 'null' &&
channel_obj.options[g].selected == true)
{
reset++;
}
}
with (theSearchForm.elements['cat_id[]'])
{
if (channels == "7")
{
categories[i] = new Option("-------", ""); i++;
categories[i] = new Option("Random Photos", "2"); i++;
categories[i] = new Option("Webinar Photos", "1"); i++;
} // END if channels
if (reset > 1)
{
categories = new Array();
}
spaceString = eval("/!-!/g");
with (theSearchForm.elements['cat_id[]'])
{
for (i = length-1; i >= firstcategory; i--)
options[i] = null;
for (i = firstcategory; i < categories.length; i++)
{
options[i] = categories[i];
options[i].text = options[i].text.replace(spaceString,
String.fromCharCode(160));
}
options[0].selected = true;
}
}
}
//]]>
[removed]
<fieldset class="search">
<input name="keywords" type="text" class="box" id="keywords" value="Search our site"
/>
<select id="channel_id" name='channel_id[]'>
<option value="null" selected="selected">Any Channel</option>
<option value="7">Photos</option>
</select>
<select id="cat_id" name='cat_id[]' class='multiselect' multiple='multiple'>
<option value='all' selected="selected">Any Category</option>
<select>
</select>
</select>
<button class="btn" title="Submit Search">Go</button>
</fieldset>
</form>I want PHOTOS to always be selected and have the categories field always populated with the categories associated with this option.
Thanks for your help.