This topic is locked

Displaying advanced search javascript bug

1/20/2010 4:10:54 PM
PHPRunner General questions
D
Dale author

When using the IE browser and clicking advanced search on a list, I would get javascript errors popping up.(firefox just ignores the errors, but using the error console, you can see they are still there.)

I tracked this down the fact I had used in the BeforeShowSearch event some assigns to hide fields from certain user groups.

Because they are hidden, the javascript in the search.php was the culprit that was throwing up the errors.
source/search.php

to fix this find the script below

if @TABLE.bSearchSuggest##

$jscode.="

foreach Fields as @f filter @f.bAdvancedSearch && (@f.strEditFormat==EDIT_FORMAT_TEXT_FIELD||@f.strEditFormat==EDIT_FORMAT_READONLY||@f.strEditFormat==EDIT_FORMAT_FILE)##

document.forms.editform.value_##@f.strName g##.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value_##@f.strName g##,'advanced')};

document.forms.editform.value1_##@f.strName g##.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value1_##@f.strName g##,'advanced1')};

document.forms.editform.value_##@f.strName g##.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value_##@f.strName g##,'advanced')};

document.forms.editform.value1_##@f.strName g##.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value1_##@f.strName g##,'advanced1')};

endfor##";



and modify it as below

if @TABLE.bSearchSuggest##

$jscode.="

foreach Fields as @f filter @f.bAdvancedSearch && (@f.strEditFormat==EDIT_FORMAT_TEXT_FIELD||@f.strEditFormat==EDIT_FORMAT_READONLY||@f.strEditFormat==EDIT_FORMAT_FILE)##

**if(document.forms.editform.value_##@f.strName g##)** document.forms.editform.value_##@f.strName g##.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value_##@f.strName g##,'advanced')};

**if(document.forms.editform.value1_##@f.strName g##)** document.forms.editform.value1_##@f.strName g##.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value1_##@f.strName g##,'advanced1')};

**if(document.forms.editform.value_##@f.strName g##)** document.forms.editform.value_##@f.strName g##.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value_##@f.strName g##,'advanced')};

**if(document.forms.editform.value1_##@f.strName g##)** document.forms.editform.value1_##@f.strName g##.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value1_##@f.strName g##,'advanced1')};

endfor##";



Also find

window.ShowHideControls = function ()

{

foreach Fields as @f filter @f.bAdvancedSearch && !IsBinaryField(@f) order @f.nAdvSearchPageOrder##

document.getElementById('second_##@f.strName g##').style.display =

document.forms.editform.elements['asearchopt_##@f.strName g##'].value==\"Between\" ? '' : 'none';

endfor##

return false;

}

and replace it with this

window.ShowHideControls = function ()

{

foreach Fields as @f filter @f.bAdvancedSearch && !IsBinaryField(@f) order @f.nAdvSearchPageOrder##

**if(document.getElementById('second_##@f.strName g##'))**

document.getElementById('second_##@f.strName g##').style.display =

document.forms.editform.elements['asearchopt_##@f.strName g##'].value==\"Between\" ? '' : 'none';

endfor##

return false;

}
I rebuilt the pages, uploaded and test, all errors are gone.
the search.php