473,387 Members | 1,573 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Question about Javascript and Perl form

Hello,

I am trying to do something unusual and it has me stumped. I am looking to
change the Env variable for RemoteUser essentially. What I would like to
happen is that the user would choose a name from the dropdown box populated
by the list in test.txt. Once the user chooses that name, the home
directory is then pointed to the chosen name and the user is able to see the
files listed in the new directory. I have included the snippet that I have
been trying to accomplish this with and would gladly appreciate some
feedback on how to make this happen.


#my $user_file = "/Volumes/data01/cgi-bin/rem_user.txt";
my $user_file = "test.txt";

# The code sections generate the pulldown boxes in the slug form.
#
# Freeform fields are populated from cookies with inline perl.
#

print $query->header ( );

print <<END_HTML;

<HTML>
<head>

<script language="JavaScript">

function changeUser(user){
remoteuser = $user;
homedir = "/Volumes/data01/Users/$remoteuser";
alert("$homedir");

}

</script>

<link rel="stylesheet" href="/catch.css" type="text/css" />
</head>
<body>
<div id="Header">
<div id="MainText">

<form action="/cgi-bin/slugreg"
enctype="multipart/form-data" name="dataBuild" onSubmit="return
verify(this.form)" method="post">

<h3> SLUG ENTRY FORM</h3>

<table>
<tr><td>
<span CLASS="intable">
Select User Name:
</td><td>
END_HTML

################################################## ##########################
###########################
###Start Media Manager special###

open (REMUSER, "$user_file") || Error('open','file');
#read (REMUSER);
my @users = <REMUSER>;

close (REMUSER);

print "<select name='uname'>\n";
foreach (@users){
print "<option value='$_'>$_'";
}

print "</select>\n";

sub Error {
print "Content type: text/html\n\n";
print "The server cannot $_[0] the $_[1]: $! \n";
exit;
}
################################################## ##########################
##########################

print <<END_HTML;
</td><td>
<input type="button" name="test" value="Change User!"
onClick="changeUser(document.dataBuild.uname.optio ns[document.dataBuild.unam
e.selectedIndex].value)">
</td></tr>

<tr><td>
<span CLASS="intable">
Select File You've Uploaded:
</td><td>
<select name="photo">

END_HTML

# -------------------------------- code /
html ---------------------------------

# This code generates a list of files in their home directory for the file
pulldown box

opendir(DIRHANDLE, "$homedir");
while ($name = readdir(DIRHANDLE)) {
open(FILEHANDLE, "$homedir/$name");
if ((-f FILEHANDLE) and ($name ne ".htaccess") and ($name ne ".DS_Store"))
{

print "<option value='$name'>$name\n";
#end if
}
#end while
}
Jul 23 '05 #1
1 1648
Scott Medaugh wrote:
<script language="JavaScript">
<script type="text/javascript">
function changeUser(user){
remoteuser = $user;
Client-side JavaScript is not PHP, variables do not start with -$-. Besides,
you're making an unnecessary assignment here.
homedir = "/Volumes/data01/Users/$remoteuser";
var homedir = "/Volumes/data01/Users/" + user;
alert("$homedir");


Once again, client-side JavaScript is not PHP. Variables don't start with -$-
and you can't embed a variable in a string and have it evaluate at run time. As
a direct replacement for what you have there, it would be:

alert(homedir);

But I'd imagine you're actually looking for something like:

location.href = homedir; // ?

If this is your intent, personally I'd submit the form to the server, have it
construct the appropriate URL path and then do print "Location: the/new/path";
to redirect the browser there. Then you have no need for a client-side
JavaScript dependence at all.

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq

Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Richard Trahan | last post by:
I want a js function to call a Perl script residing on a server. The Perl script will return a string, to be used by the js. Pseudo code: <script> stringvar = perlfunc_on_server(stringarg)...
3
by: phal | last post by:
Hi all; I code Perl for CGI, I using regular expression to check the validation of user input, because the form is small and it run only from my own computer, anyways if many people using my...
4
by: dschruth | last post by:
Hello. Can anybody solve this problem? I am using a server-side language (PERL) to *try* to POST data to a HTTPS login script that doesn't have a standard "submit" button. The form appears...
3
by: amerar | last post by:
Hi All, I have an HTML form which contains A LOT of Javascript. When submitted, a Perl/CGI program parses the form, processes the data, and reposts the new data onto the screen. Problem is,...
6
by: amerar | last post by:
Hi All, I have a form that uses Javascript to validate some fields. Whe the user selects to submit the form with certain values selected, I want to be able to execute a Perl script, query the...
10
by: Alex | last post by:
I'm not exactly sure how to use these two languages together. It seems to me that they both totally different things. PERL = databases, heavy processing, server functions. But I can also write...
2
by: joe | last post by:
I am learning Javascript by running Apache on my computer. The following question does not have Javascript because I've stripped it from a larger project. I have the following simple index.html:...
2
by: pleaseexplaintome | last post by:
Hi I have the following perl/cgi script snippet. The goal of this script is to pass a javascript variable to perl where it can be re-used later. Any help is appreciated, Thanks ...
3
by: happyse27 | last post by:
Hi All, I am creating the perl script using html form(with embedded javascript inside). When using this html form with javascript alone, it works where the form validation will pop up...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.