PDA

View Full Version : ? about parsing the HTTP substring


hogtied
01-30-2003, 12:36 AM
Hello members,

I have a script (thanks to beettle) that parses the HTTP substring for variables.

Goal: I'm trying to make a universal page that will swap out pics and text.

(ie click on solider of fortune link would go to the universal page and display SOF pics and text.
click on unreal link would go to the same universal page and display its unreal pics and text.)

so far I got the specific pics to be displayed.

Problem: I have a hidden field that also uses the substring variable. But when submitted the value does not get sent.

Here's the jscript

var g = parseGetVars();
var arSpace = new Array();
var space = g.games.split(/\+/);
document.write('<img src=\"images/games/logo_' + space[0] + space[1] + '.gif\"><input type=\"hidden\" value=\"' + g.games+ '\" name=\"name\">');

I have the script to split by plus signs in case of more than one word. How can I check to see if the string contains a plus sign or not. REASON: if it does not contain a plus sign then the pic and text does not display. In either case the value does not get sent when clicking submit...

Thanks,
Hogtied :confused:

whammy
01-30-2003, 12:47 AM
I'd use the escape() function to remedy that problem. A google search of "escape() javascript" or a visit to http://www.w3schools.com/js should give you all the info you need on it.

However, file names should really _never_ contain spaces, if you have any control over this. I'd remedy that first, since that's the TRUE source of the problem. ;)

hogtied
01-30-2003, 09:20 PM
Thanks whammy, The file does not have spaces. I need the variable in the HTTP substring to have spaces if applicable, for the heading and search criteria.

IE. I have an ad to this page for solider of fortune.
The substring looks like this ?game=solider+of+fortune

I take the substring and split by “+” if there is one. (I need to figure out how to check this). Then I load the soliderofortune image by document.write('<img src=\"images/games/' + space[0] + space[1] + '.gif\">) space[0] + space[1] is shown as "soldieroffortune" and the picture shows.

Then I capitalize the first letter of each word for the header. Solider Of Fortune.

Then I enter solide+of+fortune into a hidden form object to send as a search criteria.

The problem is when I don’t have “+”.

But Thanks whammy I’ll look into that, maybe my answer will turn up their. I’ll let you know.

hogtied
01-30-2003, 09:27 PM
I should of look at your reference before posting the above.

I understand how the escape() works and it might take a few more lines of code but I think I can get it to work.....

Thanks