Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

My code is doing something strange...

Status
Not open for further replies.

marmablue

Technical User
Dec 27, 2001
10
0
0
GB
I'm by no means experienced at JS programming, and I worked out this script to combine the contents of three form elements and send the combined result to a CGI script. The only problem is, instead of putting spaces in between the terms like it was supposed to, it puts + signs between them. Can anybody help?

The code is this:

<script language=&quot;JavaScript&quot;><!--
function textBuild() {
document.search.searchstring.value = document.search.elements[1].value+' '+document.search.elements[2].value+' '+document.search.elements[3].value
}
//--></script>
<form name=&quot;search&quot; action=&quot; onSubmit=&quot;textBuild()&quot; target=&quot;view&quot;>
<input type=&quot;hidden&quot; name=&quot;searchstring&quot;>
<input type=&quot;text&quot;><input type=&quot;text&quot;><input type=&quot;text&quot;><input type=&quot;submit&quot; value=&quot;Search&quot; target=&quot;view&quot;>

So, for example, if the word &quot;fish&quot; was typed into all three search boxes, I want the string returned to be &quot;fish fish fish&quot;, whereas it comes out as &quot;fish+fish+fish&quot;.

Can anybody help?
Thank you,
Ian
moonshadow@talk21.com
 
document.search.searchstring.value = document.search.elements[1].value+' '+document.search.elements[2].value+' '+document.search.elements[3].value

switch it to:

document.search.searchstring.value = document.search.elements[1].value' + 'document.search.elements[2].value' + 'document.search.elements[3].value

&quot;The surest sign that intelligent life exists elsewhere in the universe is that it has never tried to contact us&quot;
Bill Watterson, Calvin & Hobbes
 
If you're talking about what the searchstring looks like when you get it, a plus sign IS a space. That's part of the method of encoding urls so that special characters, like spaces, can be sent. You need to DEcode the url after you get it. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top