The idea here is that the user can only have one selection for an input text box with an id of itemURL or have a selection made for the contentPageID. If the user starts typing a response into the itemURL it makes the contentPageID dropdown back to 0 for the value which is the - Select - for the text option. If the user then changes their mind and starts to make a selection with the dropdown then it clears out the value of the itemURL text field. I've used the following code however I'm using niceforms and it has to be maniupulated a little more and not sure how.
$('contentPageID, itemURL').change ( function () {
if ( $(this).is ('select') ) {
$('itemURL').val ("");
}
else {
$('contentPageID').val (0);
}
} );
I do have a reset function that uses this to clear a dropdown but not sure how to work it into what I want to do.
$('select').each(function(){
var option = $('option:selected', this).html();
var niceselect = $(this).parents('dd').find('.NFSelectRight');
niceselect.html(option);
$(this).parents('dd')
.find('.NFSelectTarget a')
.removeClass('NFOptionActive')
.filter(':first').addClass('NFOptionActive');
});
I'm using niceforms and it has to be maniupulated a little more and not sure how.
my earlier code:
function updateNiceformSelect() {
$('select.NFhidden').each(function(){
var option = $('option:selected', this).html();
var niceselect = $(this).parents('dd').find('.NFSelectRight');
niceselect.html(option);
$(this).parents('dd')
.find('.NFSelectTarget a')
.removeClass('NFOptionActive')
.each(function(){
if($(this).html() == option)
$(this).addClass('NFOptionActive');
});
});
};
It updates niceforms select to the value of underlying html select.
http://jsfiddle.net/Jacek_FH/EwpXp/14/
Niceform uses native inputs so they do not need to be handled separately
/edit
whole working code: http://jsfiddle.net/Jacek_FH/YvGDH/5/
It was harder that I thought