• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

perl and html frames help reqd

prem

New Member
This is what i plan to do.

On page 1 : i willl have a list of urls and user can choose a list of urls and submit.
On page 2: the user will be displayed a slide show with the urls. The urls will be external links (and I cannot GET the pages). So I guess the target page needs to be a two frame page where one frame is the url and the other is the slideshow control (with Next button).

Problem is how do I do it. On submission of the form (selection of urls), I need to generate the two frames from the same perl script and so the perl script needs to pass to the slideshow controller frame the list of urls (which i cannot do through a get method).

One way is to create temp files for the controller frames. But can I do without them. Can I generate html for both the frames (atleast one frame) without cretaing any extra file.

Pls help.
 
Last edited:
I'm not quite clear as to what you exactly need. But from what I can gather this is how I can help. Please give me more info if this is not what u want.

Firstly, If you ARE using frames, and need to display external pages within your frames, why not use Javascript with target redirection?

Anyway, If you need to use Perl then you will need to create two frames dynamically. One being the top frame which contains the link and the other to display the target url. If you don't won't to create an extra file, your best option is an array. Create an array of urls so that each url maps to one unique number. For an example, $url[0] = "http://www.google.com". This numeric value is what you will have to parse using the GET method. So the actual url will read http://yoursite.com/yourscript.pl?url=x (x is the number of the url). Capture this number from the query string and increment it to create the new 'Next' button. And using this number get the actual url from the array to create the target frame.

HTH! Let me know if you need more info.
 
clarification

what i need is this:

page 1: displays a list of urls from which a user can select a list of urls, posts
via POST method to a perl script

page 2: i show him two frames, top frame shows him the control bar with next buttons and bottom frame the url (external file).

Now the top frame needs to have the list of urls to generate the next and back buttons.

Hope i make myself clear. I am open to javascript if it helps me solve the problem. If the top frame uses javascript, question is how do i display a 2 framed page from a perl script without creating any file.
 
Last edited:
and one more thing

one more thing,
the list of urls i allow the user to choose from changes every day :)
 
Last edited:
Could we be a bit more specific about the quanitity of available and most likely selectable urls.

Cos, if it's a low figure, you could POST the urls itself to create the top frame using javascript, so that you don't have to run the Perl script everytime. We are talking about using the POST url's to create an array in javascript and generate the nav buttons at client side. Therefore a javascript counter can be implemented so that everytime a user clicks on the 'Next' button the value of the counter is incremented to map to the next url in the array. The mechanism here is that the top frame doesn't refresh, it's only the bottom one getting redirected to the target url. However, you should do this only if the quantity is low. Else using a flat file will be helpful to create BOTH page 1 and page 2 dynamically.

Did it do any good ?
 
my page 1 (list of choice of urls) has no frames .
so when a user submits his choice, i need to generate the two frames.
i m ok with the top frame being based on jscript but how do i
go from a single html to 2 frame html file and that too passing the params.
 
That's no problem. You will obviously be using a form on page1 for the user to select the urls (Isn't it so). If it is, then this form should be submitted to the perl script with the selected urls. It's like this. Your page1 would contain a form in the following format

<form name="form1" method="GET" action="script.pl">
<select name="urls" multiple>
<option value="http://google.com">Google</option>
<option value="http://yahoo.com">Yahoo</option>
<option value="http://msn.com">MSN</option>
</select>
<input type="submit" value="Submit">
</form>

When the user selects multiple urls and submits it, the perl script will be called along with selected urls. Your query string data will read as http://yoursite.com/script.pl?urls=http://google.com&urls=http://yahoo.com. Using perl you can directly access these data. I assume you already know how to do it. If not, it's something like this.

if($ENV{'REQUEST_METHOD'} eq 'GET') {
$string = $ENV{'QUERY_STRING'};
$string =~ s/\+/ /g;
@urls=split(/\&/,$string);
$i = 1;
foreach $i (@urls) {
($field,$data) = split(/=/,$i);
$field =~ s/%(..)/pack("c",hex($1))/ge;
$data =~ s/%(..)/pack("c",hex($1))/ge;
$url{$i}=$data;
i++;
}
}

Now that you've got the selected url's all you have to do is create the framed page. The best option here is to go for an inline frame (IFRAME), but there are certain compatibility issues and IMO it's very unstable. Anyway, to go ahead, you will have to first create you javascript code. That using Perl itself. It would be something like,

print "Content-type: text/html\n\n";
print<<EOF;
<html><head><title>URL Navigation</title></head>
<body onload="jump(1);">
<script language="javascript">
function jump(uid){
var urls = new Array();
EOF
for($c=1; $c <= $i; $c++){
print "urls[$c] = \"$url{$c}\";\n";
}
print<<EOF;
var i = uid;
i++;
document.write("<input type=\"button\" value=\"Next\" onClick=\"jump("+i+");\">";
document.write("<hr>");
document.write(''<IFRAME SRC=\""+urls[uid]+"\" WIDTH=\"800\" HEIGHT=\"400\"></IFRAME>");
}
</script>
</body>
</html>
EOF

That's about it. Please don't expect this to work as I just typed it now and did not have time to test it. I'm sure there are lot of bugs. Anyway I just wanted to give you an idea of how to approach it. Nevertheless I would reccommend using a flat file as it would be easier and far more stable than this one. Let me know how you faired.
 
thanks a lot

thanks a lot for the reply.

I avoided the iframe method as its worser than frames as far as copyright issues are concerned (as all the urls are external).

I have the list of urls in a file. And on page 1, i provide the choie of urls from the list. So what i finally do is create two frames , where top frame is slideshow.pl?2x5x23x45x
where 2 , 5 , 23, 45 are the url numbers.

slideshow.pl takes care of the remaining stuff.

I wanted to avoid a new file for each user and thats why i had to use this method.

thanks a lot ...
prem
 
I avoided the iframe method as its worser than frames

As a matter of fact, I even hate normal frames. I never use them for my personal work. Anyway It's nice to hear you've tried out something. So does it work ? Cos, from what I can get you are trying to use the perl script on the top frame. If this is the case, then you will have to find a way to get the parsed url values into the script itself. coz when the slideshow.pl is embedded in a frame it cannot access ev data of higher frames.

I wanted to avoid a new file for each user and thats why i had to use this method.
Why didn't you say so earlier ? You DON'T have to create a new file for each user. All you do is create ONE file, store it on your server. This file would index the urls, meaning it would have a unique id for each url. When the user submits the form, the url id's are parsed. That's where you will open the file using perl and get the corresponding urls to create your slideshow page.
 
Back
Top