PDA

View Full Version : Using a variable to build a URL


Neocoder
04-07-06, 12:15 AM
Hi - I'm fairly new to scripting. I have an HTML form that captures the reader's zip code in a variable named [SEL]. I want to use that information to build a URL that will redirect to an external site.

The zip appears in the middle of the long URL string. I don't know how to convert this string which contains the zip-code variable to a literal string that I can use in my frames source statement.

My web host uses Miva 3.97.

I'll attach the code I'm trying. One problem I'm having is that if I put the entire external URL into the variable, the frame src statement thinks I'm using relative addressing, but if I type "http" in the src statement followed by the variable name, the two parts do not work together.

Thanks in advance for any advice,
neocoder

<html>
<head>
<title>Census test with frame</title>
</head>
<MIVA DEFAULTMACROENCODING="entities">
<miva standardoutputlevel="html,text,compresswhitespace">
<MvASSIGN NAME="redirect-url" VALUE="factfinder.census.gov/servlet/QTTable?_bm=y&-geo_id=86000US&[SEL]&-qr_name=DEC_2000_SF3_U_DP3&-ds_name=DEC_2000_SF3_U&-_lang=en&-redoLog=false&-_sse=on">

<frameset rows="0,*" cols="*" frameborder="no" border="0"
framespacing="0" scrolling="no">=20
<FRAME SRC="null.mv" NAME="title" SCROLLING="no" MARGINHEIGHT="0"
MARGINWIDTH="2">

<frame name="redir_frame" src="http://&[redirect-url]">
</frameset>
<noframes>
<body>

Vic - WolfPaw Computers
04-07-06, 12:23 AM
Any of your form fields passed in the URL can be referenced as global variables, thus it would appear geo_id is the zip, thus g.geo_id could be used.

webfarm
04-07-06, 08:05 AM
For starters, write it securely rather than with macros:

<html>
<head>
<title>Census test with frame</title>
</head>
<miva standardoutputlevel="html,text,compresswhitespace" >
<MvASSIGN NAME="g.redirect-url" VALUE="{'factfinder.census.gov\/servlet\/QTTable?_bm=y&amp;-geo_id=86000US' $ g.SEL $ '&amp;-qr_name=DEC_2000_SF3_U_DP3&amp;-ds_name=DEC_2000_SF3_U&amp;-_lang=en&amp;-redoLog=false&amp;-_sse=on'}">

<frameset rows="0,*" cols="*" frameborder="no" border="0"
framespacing="0" scrolling="no">=20
<FRAME SRC="null.mv" NAME="title" SCROLLING="no" MARGINHEIGHT="0"
MARGINWIDTH="2">

<frame name="redir_frame" src="{'http://' $ g.redirect-url}">
</frameset>
<noframes>
<body>

actually you needn't bother defining the url as a redirect, just plug it straight in to the src attribute.

Neocoder
04-07-06, 10:46 PM
Thank you for your help. I am so happy that this code is finally working after I struggled with it for two days. You guys are great!