Selecting an option based on Body ID
Hi all,
I am trying to create a form (that is present on every page) that has a drop down list of options.
I want each option to relate to a particular page so if I go to Page 1 then the option Page 1 appears in the select box. Of course they can choose any of the other options.
So far I have -
-
$(document).ready(function() {
// Get the bodyid of the page
var home = ' Corporate Cars ';
var airport = ' Airport Transfers ';
var tours = ' Tours ';
var group = ' Group Transfers ';
var bodyid = $("body").attr("id");
if (bodyid == 'home') {
$('#fm_refer').val( home );
}
else if (bodyid == 'airport') {
$('#fm_refer').val( airport );
}
else if (bodyid == 'tours') {
$('#fm_refer').val( tours );
}
else if (bodyid == 'group') {
$('#fm_refer').val( group );
}
});
Which is great for an input text box but I can't find the right information when it comes to a select box.
Any help?!