Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Microsoft JScript runtime error: 'document.jksearch.se' is null or not an object
^^^^^^^^ above mentioned line is the error message.

XML
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="mysearch1.aspx.vb" Inherits="comment.aspx.mysearch1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server" name="jksearch" action="http://www.google.com/search" method="get" onsubmit="jksitesearch(this)" >


Search Engine :<br /><br />
<input id="hiddenquery" type="hidden" name="q" />
<input name="qfront" type="text" style="width: 200px" value="navigator object" /> <input type="submit" value="Search" /><br /><br />
<div style="font: bold 11px Verdana;">Google:<input name="se" type="radio" checked="checked"/>  Yahoo:<input name="se" type="radio"/>  MSN:<input name="se" type="radio"/>
</div>
<p>
<script type="text/javascript">

    // All-in-one Internal Site Search script- By JavaScriptKit.com (http://www.javascriptkit.com)
    // For this and over 400+ free scripts, visit JavaScript Kit- http://www.javascriptkit.com/
    // This notice must stay intact for use

    //Enter domain of site to search.
    var domainroot = "www.javascriptkit.com"

    var searchaction = [ //form action for the 3 search engines
"http://www.google.com/search",
"http://search.yahoo.com/search",
"http://search.msn.com/results.aspx"
]

    var queryfieldname = ["q", "p", "q"] //name of hidden query form for the 3 search engines

    function switchaction(cur, index)
     {
        cur.form.action = searchaction[index]
        document.getElementById("hiddenquery").name = queryfieldname[index]
    }

    function jksitesearch(curobj)
     {
         for (i = 0; i < document.jksearch.se.length;i++ )
        { //loop through radio to see which is checked
            if (document.jksearch.se[i].checked == true)
                switchaction(document.jksearch.se[i],i)
        }
        document.getElementById("hiddenquery").value = "site:" + domainroot + " " + curobj.qfront.value
    }


</script>

</p>


<script type="text/JavaScript">


    //
    // Script by Jari Aarniala [www.mbnet.fi/~foo -- foo@mbnet.fi]
    //
    // This script makes it easy to choose with which search engine
    // you`d like to search the net. You may use this if you keep this
    // text here...
    //

    function startSearch() {
        searchString = document.searchForm.searchText.value;
        if (searchString != "") {
            searchEngine = document.searchForm.whichEngine.selectedIndex + 1;
            finalSearchString = "";

            if (searchEngine == 1) {
                finalSearchString = "http://www.altavista.digital.com/cgi-bin/query?pg=q&what=web&fmt=.&q=" + searchString;
            }
            if (searchEngine == 2) {
                finalSearchString = "http://av.yahoo.com/bin/query?p=" + searchString + "&hc=0&hs=0";
            }
            if (searchEngine == 3) {
                finalSearchString = "http://www.excite.com/search.gw?trace=a&search=" + searchString;
            }
            if (searchEngine == 4) {
                finalSearchString = "http://www.hotbot.com/?SW=web&SM=MC&MT=" + searchString + "&DC=10&DE=2&RG=NA&_v=2&act.search.x=89&act.search.y=7";
            }
            if (searchEngine == 5) {
                finalSearchString = "http://www.infoseek.com/Titles?qt=" + searchString + "&col=WW&sv=IS&lk=noframes&nh=10";
            }
            if (searchEngine == 6) {
                finalSearchString = "http://www.lycos.com/cgi-bin/pursuit?adv=%26adv%3B&cat=lycos&matchmode=and&query=" + searchString + "&x=45&y=11";
            }
            if (searchEngine == 7) {
                finalSearchString = "http://netfind.aol.com/search.gw?search=" + searchString + "&c=web&lk=excite_netfind_us&src=1";
            }

            location.href = finalSearchString;
        }
    }



</script>

<basefont size="" face="Verdana, Arial, sans-serif"/>

<table width="320" border="2" cellpadding="3" cellspacing="2" bgcolor="#ff6600">


<tr>
<td bgcolor="lightblue"><font size="1" face="Verdana, Arial, sans-serif"/>Search for:</td>
<td bgcolor="lightblue"><font size="1" face="Verdana, Arial, sans-serif"/>Search from:</td>
<td bgcolor="lightblue">&nbsp;</td>
</tr>
<tr>
<td bgcolor="navajowhite"><input style="background: dddddd" name="searchText" type="text"/></td>
<td bgcolor="navajowhite"><select style="background:dddddd" name="whichEngine" >
<option>Altavista</option>
<option>Yahoo!</option>
<option>Excite</option>
<option>Hotbot</option>
<option>Infoseek</option>
<option>Lycos</option>
<option> AOL Netfind</option>
</select></td>

<td bgcolor="navajowhite"><input type="button" value="Send" onclick="startSearch()"/></td>
</tr>



</table>
</form>






</body>
</html>


Additional info from comment below
error comes in following line....
for (i = 0; i < document.jksearch.se.length;i++ )
Posted
Updated 6-Jun-12 11:25am
v3
Comments
R. Giskard Reventlov 6-Jun-12 14:28pm    
Do you have an actual question? BTW: only add code that is directly related to the problem you require help with: no one has the time to wade through everything!
Sergey Alexandrovich Kryukov 6-Jun-12 14:51pm    
Right. I always insist that in complex problems inquirers should create a code complete but short sample focused on a specific problem, specially for the CodeProject question.
First, it helps to isolate problem, which itself can lead to its resolution without asking CodeProject. And finally, it makes the question answerable.
--SA
nicky_008 6-Jun-12 14:54pm    
error comes in following line....
for (i = 0; i < document.jksearch.se.length;i++ )
R. Giskard Reventlov 6-Jun-12 14:56pm    
Edit your question to show this.
nicky_008 6-Jun-12 15:02pm    
Microsoft JScript runtime error: 'document.jksearch.se' is null or not an object...this is an error message.

1 solution

Hi,

I don't think you can access the radio collection named 'se' in the way you're trying to. Replace this code:

JavaScript
function jksitesearch(curobj)
     {
         for (i = 0; i < document.jksearch.se.length;i++ )
        { //loop through radio to see which is checked
            if (document.jksearch.se[i].checked == true)
                switchaction(document.jksearch.se[i],i)
        }
        document.getElementById("hiddenquery").value = "site:" + domainroot + " " + curobj.qfront.value
    }

With:
C#
function jksitesearch(curobj)
     {
         var se = document.getElementsByName('se');
         for (i = 0; i < se.length;i++ )
        { //loop through radio to see which is checked
            if (se[i].checked == true)
                switchaction(se[i],i)
        }
        document.getElementById("hiddenquery").value = "site:" + domainroot + " " + curobj.qfront.value
    }
 
Share this answer
 
Comments
nicky_008 7-Jun-12 3:59am    
yeah...finally it work's....thankss for your help
VJ Reddy 10-Jun-12 5:03am    
Good answer. 5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900