|
-
May 12th, 2004, 08:26 AM
#1
Thread Starter
Frenzied Member
strings with spaces [Resolved]
Ok, so I have the following function:
Code:
function gofull()
{
URL = location.href
if (URL.search("Date_Found") != -1)
{
URL = URL.substring(0,URL.search("Date_Found")-1)
}
URL=URL+"?Date_Found="+document.dform.Date_Found.value+"&Last_Known="+document.dform.Last_Known.value
if (document.dform.TagNum.options[document.dform.TagNum.selectedIndex].value != 1)
URL = URL+"&TagNum="+document.dform.TagNum.options[document.dform.TagNum.selectedIndex].value
if (document.dform.SYMP.value != "")
URL = URL+"&SYMP="+document.dform.SYMP.value
if (document.dform.User.options[document.dform.User.selectedIndex].value != 1)
URL = URL+"&user="+document.dform.User.options[document.dform.User.selectedIndex].value
if (document.dform.impact.value != "")
URL = URL+"&impact="+document.dform.impact.value
URL = URL+"&act_prod_date="+document.dform.act_prod_date.value
location.href = URL
}
-->
</script>
It works great except for the fact that the "SYMP" field is a string that will contain spaces. When that field is put into the URL when the form is refreshed, it adds "%20" for each space... and then when I use the following:
PHP Code:
<?php
if(isset($_GET['SYMP']))
echo "<input type=text name=SYMP size=40 value=" . $_GET['SYMP'] . ">";
else
echo "<input type=text name=SYMP size=40 value=\"\">";
?>
it only puts the first word of the string into the textbox.
How do I get it to grab the whole string out of the URL?
Last edited by ober0330; May 12th, 2004 at 10:43 AM.
-
May 12th, 2004, 08:33 AM
#2
Frenzied Member
When SYMP is set, replace all spaces with another character, maybe dash.
SYMP.replace(" ", "-")
Then when PHP reads it, it can replace all dashes back to spaces.
Have I helped you? Please Rate my posts. 
-
May 12th, 2004, 10:10 AM
#3
Thread Starter
Frenzied Member
That only seems to work for the first space.
-
May 12th, 2004, 10:15 AM
#4
Thread Starter
Frenzied Member
-
May 12th, 2004, 10:28 AM
#5
Frenzied Member
only replaces first space???
How are you replacing them?
Have I helped you? Please Rate my posts. 
-
May 12th, 2004, 10:36 AM
#6
Thread Starter
Frenzied Member
I was doing this:
Code:
if (document.dform.SYMP.value != "")
URL = URL+"&SYMP="+document.dform.SYMP.value.replace(" ","-")
-
May 12th, 2004, 10:39 AM
#7
Look at the Server object, there should be a URLEncode and URLDencode functions. One changes the string to make it URL ready (adds the %20 where spaces are) and the other Dencodes if from URLEncoded back to regular string (the %20 turn back into spaces). Doing a replace space with - or _ while it works, it's not ideal, since a - or _ are (in theory) valid values in the string to begin with (wouldn't want a a space when it wasn't supposed to be there.
TG
Whoopse, just saw that this was PHP, the URLEncode and URLDencode still stand, they are functions built into PHP.
-
May 12th, 2004, 10:42 AM
#8
Thread Starter
Frenzied Member
ok... nevermind. I'm an idiot. It was all in how I was feeding it back into the textbox. I don't have to do ANY kind of replacing. It does it automatically.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|