Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 353
  • Last Modified:

change special characters

i need the users to type a keyword in a 'google like' seachbar (then click a button named'search').  after clicking, the keyworld would replace all special this characters ## (or any other character you suggest) in this scripts.

<li><a class="current" href="" onClick="return handlelink(this)">Google</a></li>
<li><a href="" onClick=+##"return handlelink(this)">Yahoo</a></li>

<iframe name="cwindow" style="border:2px solid black" width=479 height=219 src="" target="cwindow"></iframe>
<iframe name="cwindow" style="border:2px solid black" width=479 height=219 src="" target="cwindow"></iframe>

i'm a newbie to would be useful (very very much) if anybody can write the entire script.thank you.
  • 4
  • 4
1 Solution
Not sure what you want to do. Replace is done using the replace function.
<script type=text/javascript>
var rx=/\#\#/g
var s=""
var search="some string"
alert(s.replace(rx, search));

But based on the code you gave, try this: multiSiteSearch.htm
Do you want the '##' in <li><a class="current" href="" onClick="return handlelink(this)">Google</a></li>
to be replaced with whatever you typed in the searchbar?


Whatever you typed in the searchbar to be replace with '#'?
arasuworldAuthor Commented:
the first one. that is,  ## in <li><a class="current" href="" onClick="return handlelink(this)">Google</a></li>
will be replaced with whatever users typed in the searchbar.
Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

Try my demo from the sendspace link. Took almost an hour to make & may be just what you need.
arasuworldAuthor Commented:
the multisitesearch is exactly what i looking for, but i have huge set of iframes ( in many saiz and position in webpage) that i have already designed. so i'm looking for just the onclick (searchbar) script. something like the replace function that callrs gave ( but not working). i stress again that the multisite search is exactly what i was looking (perfectly) for but i already did the webpage layout with iframes so i just need search bar replace function.
callrsCommented: replacehref.htm

Hover over the Google & Yahoo links & read the full text in the status bar. Then click "Replace", then hover over the links again to see that they've changed.
arasuworldAuthor Commented:
i'm trying all the scripts you gave me.please wait until i test everthing in my website and post a feedback.
arasuworldAuthor Commented:
i have a script like this (script 1) .i'm looking for a script like this but would do exactly what multisite search would do. the user input would replace/add/submit (any one of these) to other search engin in iframe.(script2-which already inplace in my site)


<form action="
" method="replace">
<h6 align="center">
<input type="hidden" name="p" value="1" />
<input type="hidden" name="lang" value="en" />
<input type="hidden" name="include" value="" />
<input type="hidden" name="exclude" value="" />
<input type="hidden" name="penalty" value="0" />
<font color="#FFFFFF"> Search for:</font>
<input type="text" name="q" />
<input type="submit" value="Search" name="submit" />


<li><a class="current" href="" onClick="return handlelink(this)">Google</a></li>
<li><a href="http://" onClick="return handlelink(this)">Yahoo</a></li>
<li><a href="" onClick="return handlelink(this)">MSN</a></li>

Thanks. Here's the code for reference:

<!-- Mulit site search
      2006-10-31 RS
<script type="text/javascript">
function handlelink(obj, frameid){
var search, url, addon="";
search=document.forms.form1.In1.value.split(" ");
for (i=0; i<search.length-1; i++) addon=addon+search[i]+"+"
return false;

<body onload='document.forms.form1.In1.focus()'>
<li><a id=link1 class="current" href="" onClick="return handlelink(this,'cwindow1')">Google</a></li>
<li><a id=link2 href="" onClick="return handlelink(this,'cwindow2')">Yahoo</a></li>
<form name=form1 onsubmit="handlelink(document.getElementById('link1'),'cwindow1'); return handlelink(document.getElementById('link2'),'cwindow2')">
Search query: <input name=In1 value="apples oranges">
<input type=submit name="Search" >
<iframe name="cwindow1" id="cwindow1" style="border:2px solid black" width=479 height=519 src=""></iframe>

<iframe name="cwindow2" id="cwindow2" style="border:2px solid black" width=479 height=519 src="">/iframe>

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now