Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Problem with Javascript function......Please Help.
Old 06-28-2010, 01:55 AM Problem with Javascript function......Please Help.
Isabella_Smith's Avatar
Ultra Talker

Posts: 285
Trades: 0
Hi,

I am using a javascript given below, but this is not working for the company condition. I am calling a company name from database such as:

Company Name (LOCATION)
Company Name2 (LOCATION)

The script having following problems:

1. Its not checking NULL value for the text box "Keyword".
2. If I am writing something without "()" it doesn't search. But It works fine when I added "()" after any company name.

Please let me know where I mistook.

HTML Code:
function doSearch()
 {
        //alert("I am here");
        doSub=true; var dd = document.getElementById('city_name');
        var areaname=document.getElementById('keyword').value; var c = document.getElementById('city_name').value;
        if(document.getElementById('company').checked){
            var areaname_x = areaname.split("  (");
            var areaname_y = areaname_x[1].split(")");
            //change the action value of the first form
            document.getElementsByTagName('form')[0].action="srch/serch_name.php?city="+c+"&title="+encodeURIComponent(areaname_x[0])+"&area="+escape(areaname_y[0])+"";
            if(document.getElementById('city_name').value==""||document.getElementById('city_name').value=="Select City")
            {
                alert("Please select city first!");
                document.getElementById('city_name').focus();
                    doSub=false;
               }

            else if(document.getElementById('keyword').value==""){
                alert("Please enter category / company name for search.");
                document.getElementById('keyword').focus();
                   doSub=false;
            }
        }
        
        else{ var b=document.getElementById('keyword').value; var c = document.getElementById('city_name').value;
            document.getElementsByTagName('form')[0].action="srch/serch_keywords.php?city="+c+"&title="+encodeURIComponent(b)+"";
           if(document.getElementById('city_name').value==""||document.getElementById('city_name').value=="Select City"){
                alert("Please select city first!");
                document.getElementById('city_name').focus();
                    doSub=false;
               }
            else if(document.getElementById('keyword').value==""){
                alert("Please enter category / company name for search.");
                document.getElementById('keyword').focus();
                doSub=false;
            }
        }
        //submit the form
        if(doSub===true){
            document.getElementsByTagName('form')[0].submit();
        }
}
Your help would be highly appreciated.


Thanks
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE



Please login or register to view this content. Registration is FREE
buy all indian salwar Kameez, Sarees and clothes
Isabella_Smith is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-30-2010, 03:39 PM Re: Problem with Javascript function......Please Help.
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Because the function uses the split function with paranthesis as the characters to split on.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?

Last edited by chrishirst; 06-30-2010 at 03:42 PM..
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Problem with Javascript function......Please Help.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.16054 seconds with 12 queries