NameSilo

I hate JavaScript - Please help, I don't know what's wrong!

Spaceship Spaceship
Watch

PoorDoggie

Soon to be RICHdoggie!VIP Member
Impact
18
I don't know what is wrong here... there are no errors or anything, its just not showing up! :(

this is the code kept in "searchbar.js":
Code:
function checkform(form){
  if(form["q"].value == ""){
   alert("Please insert keyword(s) to search for");
    form["q"].focus();
    return false ;
  }
  return true;
}
function toProperCase(astring){
  return astring.toLowerCase().replace(/\w+/g,function(s){return s.charAt(0).toUpperCase() + s.substr(1);})
}
function changemode(newmode){
  document.getElementById("m").value=newmode.toLowerCase();
  document.getElementById("web").className="standardmode";
  document.getElementById("Local").className="standardmode";
  document.getElementById("Images").className="standardmode";
  document.getElementById("News").className="standardmode";
  document.getElementById("Video").className="standardmode";
  document.getElementById("Domains").className="standardmode";
  document.getElementById(newmode).className="newmode";
  if(newmode == "Local"){
    document.getElementById("q").style.width="110px";
    document.getElementById("localSearchBar").innerHTML=" <input name=\"location\" id=\"location\"style=\"width: 100px\" value=\"Location\" onFocus=\"if(this.value=='Location'){this.select();}\" title=\"e.g. NY or Zip Code\" />";
  }
  else{
    document.getElementById("q").style.width="220px";
    document.getElementById("localSearchBar").innerHTML="";
  }
}

if(6_logo=='no'){
  var sixsearch_logo = '';
}
else{
  var sixsearch_logo = '<td rowspan="2" valign="middle"><a href="http://sixsearch.net"><img src="http://sixsearch.net/adverts/images/six.gif" style="border:0" alt="Search the Web with Six Search - www.sixsearch.net" /></a></td>';
}

if(6_search_the_web=='no'){
  var sixsearch_stw = '';
}
else{
  var sixsearch_stw = '<td rowspan="2" valign="middle"><a href="http://sixsearch.net"><img src="http://sixsearch.net/adverts/images/searchtheweb.gif" style="border:0" alt="Search the Web with Six Search - www.sixsearch.net" /></a></td>';
}

var sixsearch = '<style>.newmode{font-family: Verdana, Arial, sans-serif;font-size: 13px;color: #'+6_text_color+';font-weight: bold;text-decoration: none;cursor: default;display: inline;}.standardmode{font-family: Verdana, Arial, sans-serif;font-size: 13px;color: #'+6_text_color+';text-decoration: underline;font-weight: normal;cursor: hand;cursor: pointer;display: inline;}</style><form method="get" action="http://sixsearch.net/search.php" name="search" onsubmit="return checkform(this);" target="_blank"><table cellpadding="0" cellspacing="0" border="0" style="background: #'+6_bg_color+';color: #'+6_text_color+';"><tr>'+sixsearch_logo+''+sixsearch_stw+'<td style="color: #ffffff;font-size: 8px"><div onClick="changemode(\'web\')" class="newmode" id="web">Web</div> | <div onClick="changemode(\'Local\')" class="standardmode" id="Local">Local</div> | <div onClick="changemode(\'Images\')" class="standardmode" id="Images">Images</div> | <div onClick="changemode(\'News\')" class="standardmode" id="News">News</div> | <div onClick="changemode(\'Video\')" class="standardmode" id="Video">Video</div> | <div onClick="changemode(\'Domains\')" class="standardmode" id="Domains">Domains</div></td></tr><tr><td><input name="q" id="q" style="width: 220px;" /><div id="localSearchBar" style="display: inline;"></div><input type="hidden" name="m" id="m" value="web" /> <input type="submit" name="sixBtn" id="sixBtn" value="Search" /></td></tr></table></form>';

document.write(sixsearch);

and this is how it is called:
Code:
<script type="text/javascript">
		  6_bg_color = '811A20';
		  6_text_color = 'ffffff';
		  6_logo = 'yes';
		  6_search_the_web = 'yes';
		</script>
		<script type="text/javascript" src="http://sixsearch.net/adverts/searchbar.js"></script>

I can't see what is wrong, and if I substitute the src="http://... to something else then it shows up perfectly. I don't know what is wrong! :( Can anyone help me!? please!! lol

Thanks for your help! :D
Tom
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
I couldn't tell you what the problem is, but if you're using Firefox you should have a look in the Javascript Console (under Tools) for errors.

Javascript doesn't generally show errors on screen... it just fails silently. In the console you can see if you have any actual errors.
 
1
•••
right, thanks will try that



no, i think I got it, is it because im using numbers in my variables?
 
Last edited:
0
•••
Ah yes, that would be a problem. You can have numbers in your variable name, they just can't be the first character in the name...
 
0
•••
yea, it works now :)

Thanks
Rep added
 
0
•••
I hate javascript too :(

really sucks, VBscript is a lot better
 
0
•••
you see, javascript is easy(ish) if you know php. I have always thought that vbscript is object orientated etc... and just a pain in the backside! lol

Hey, I will look into it, thanks.
 
0
•••

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back