Click to See Complete Forum and Search --> : why won't this code work together?


hchritton
08-13-2003, 08:43 AM
Can someone help me with this very frustrating problem?

I have two pieces of code that work fine with they are in separate pages (see below), but as soon as I combine the code into one page it stops working.

Code #1 - http://libtest.gatech.edu/gilquicksearch.html
Code #2 - http://libtest.gatech.edu/header.html

In code #1 the javascript takes whatever text you type into the search box and wraps it with quotes if you choose "search for a pharse" from the dropdown menu, or it inserts a plus sign between each word you typed in the search box if you choose "find all words" from the dropdown menu.

When the code #1 and code #2 are combined into one page the search box (code #1) no longer functions properly, but the header created by code #2 works fine. Two things are happening, First, the dropdown menu does not even appear on the page. Secondly, the plus signs or quotes are no longer added to the text that's typed into the search box.

Combined Code - http://libtest.gatech.edu/tempcode.htm

Here is the error message I receive -
Error: submit_form is not defined Line: 173

PLEASE HELP! Thanks.

pyro
08-13-2003, 08:51 AM
That is trying to call the function submit_form(). I did a search through the source, and you don't have any function named submit_form(). Then, I took a look at the other page you linked to (http://libtest.gatech.edu/gilquicksearch.html) and found these two functions. Try including them on the page:

function replace_characters()
{
document.forms['voyagerquerybox'].FT.value= document.forms[0].FT.value.replace(/\+/g,"");
document.forms['voyagerquerybox'].FT.value= document.forms[0].FT.value.replace(/\"/g,"");
document.forms['voyagerquerybox'].FT.value= document.forms[0].FT.value.replace(/\?/g,"");
document.forms['voyagerquerybox'].FT.value= document.forms[0].FT.value.replace(/\*/g,"");
}

function submit_form()
{
current_selection = document.forms['voyagerquerybox'].phrase_type.selectedIndex;

if(current_selection ==1)
{
replace_characters();
document.forms['voyagerquerybox'].FT.value='"' + document.forms['voyagerquerybox'].FT.value + '"';
}
else if(current_selection ==2)
{
replace_characters();
document.forms['voyagerquerybox'].FT.value= "+"+document.forms['voyagerquerybox'].FT.value;
document.forms['voyagerquerybox'].FT.value= document.forms['voyagerquerybox'].FT.value.replace(/ /g," +");
}
else if(current_selection ==0)
{
replace_characters();
}
}

hchritton
08-13-2003, 09:02 AM
I added the code you requested and it's still not working.

The dropdown menu now appears, but the search box still does not function properly.

Now I get the following error message -

Error: document.forms[0].FT has no properties Line: 109

Thanks!

pyro
08-13-2003, 09:07 AM
It seems to be working for me (IE6). A search for "test" returned http://gil.gatech.edu/cgi-bin/Pwebrecon.cgi?FT=test&HIST=1&CNT=25+records+per+page&phrase_type=3&SUBMIT=Go

hchritton
08-13-2003, 09:22 AM
It searches, but it doesn't search properly.

When you type in text in the search box, for example -

this is a test

and choose "find all words" from the drop down menu when you hit the GO button it should add a + sign between each word.

this+is+a+test

but it doesn't, so therefore it's not searching for all words.

If you type in -

this is a test

and choose "search for a pharse" from the drop down menu it should put quotes around your search when you hit the GO button, but it doesn't

"this is a test"

If you try a search on the Code #1 page - http://libtest.gatech.edu/gilquicksearch.html you will see the search box functioning properly.

I don't understand what is causing the conflict when the code is combined.