Solved

change special characters

Posted on 2006-10-31
9
334 Views
Last Modified: 2013-12-03
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="http://www.digg.com=+##" onClick="return handlelink(this)">Google</a></li>
<li><a href="http://www.reddit.com" onClick=+##"return handlelink(this)">Yahoo</a></li>

<iframe name="cwindow" style="border:2px solid black" width=479 height=219 src="http://www.digg.com+##" target="cwindow"></iframe>
<iframe name="cwindow" style="border:2px solid black" width=479 height=219 src="http://www.reddit.com+##" target="cwindow"></iframe>

i'm a newbie to javascript.it would be useful (very very much) if anybody can write the entire script.thank you.
0
Comment
Question by:arasuworld
  • 4
  • 4
9 Comments
 
LVL 30

Accepted Solution

by:
callrs earned 500 total points
Comment Utility
Not sure what you want to do. Replace is done using the replace function.
E.g.
<script type=text/javascript>
var rx=/\#\#/g
var s="http://www.digg.com=+##"
var search="some string"
alert(s.replace(rx, search));
</script>

But based on the code you gave, try this: http://www.sendspace.com/file/5yjlrj multiSiteSearch.htm
0
 

Expert Comment

by:argus42
Comment Utility
Do you want the '##' in <li><a class="current" href="http://www.digg.com=+##" onClick="return handlelink(this)">Google</a></li>
to be replaced with whatever you typed in the searchbar?

OR

Whatever you typed in the searchbar to be replace with '#'?
0
 

Author Comment

by:arasuworld
Comment Utility
the first one. that is,  ## in <li><a class="current" href="http://www.digg.com=+##" onClick="return handlelink(this)">Google</a></li>
will be replaced with whatever users typed in the searchbar.
0
 
LVL 30

Expert Comment

by:callrs
Comment Utility
Try my demo from the sendspace link. Took almost an hour to make & may be just what you need.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:arasuworld
Comment Utility
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.
0
 
LVL 30

Expert Comment

by:callrs
Comment Utility
http://www.sendspace.com/file/lg1l26 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.
0
 

Author Comment

by:arasuworld
Comment Utility
i'm trying all the scripts you gave me.please wait until i test everthing in my website and post a feedback.
0
 

Author Comment

by:arasuworld
Comment Utility
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)

SCRIPT1

<form action="http://www.mysite.com
" 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" />
</h6>
</form>


SCRIPT 2

<li><a class="current" href="http://www.google.com/search?hl=en&q=" onClick="return handlelink(this)">Google</a></li>
<li><a href="http://http://search.yahoo.com/search?p=" onClick="return handlelink(this)">Yahoo</a></li>
<li><a href="http://search.msn.com.sg:80/results.aspx?q=" onClick="return handlelink(this)">MSN</a></li>







0
 
LVL 30

Expert Comment

by:callrs
Comment Utility
Thanks. Here's the code for reference:

<html>
<!-- Mulit site search
      2006-10-31 RS
-->
<head>
<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]+"+"
addon=addon+search[search.length-1]
url=obj.href+addon;
document.getElementById(frameid).src=url;
//window.frames[frame_].src=url;
return false;
}

</script>
</head>
<body onload='document.forms.form1.In1.focus()'>
<li><a id=link1 class="current" href="http://www.google.com/search?q=" onClick="return handlelink(this,'cwindow1')">Google</a></li>
<li><a id=link2 href="http://search.yahoo.com/search?p=" 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" >
</form>
<iframe name="cwindow1" id="cwindow1" style="border:2px solid black" width=479 height=519 src="http://www.google.com/search"></iframe>

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

</html>
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now