473,839 Members | 1,472 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="JavaS cript">

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="multip art/form-data" name="dataBuild " onSubmit="retur n
verify(this.for m)" 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','f ile');
#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="change User(document.d ataBuild.uname. options[document.dataBu ild.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(DIRHAND LE, "$homedir") ;
while ($name = readdir(DIRHAND LE)) {
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 1676
Scott Medaugh wrote:
<script language="JavaS cript">
<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*****@agrico reunited.com>
comp.lang.javas cript 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
15905
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) document.write(stringvar) </script> Can stringvar above be a url?
3
2472
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 form, do you think it will be slow due to Perl is run under server. How about using JavaSCript to check validation for user input? Do you think it a bit faster?
4
16288
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 to use javascript to submit the document via the browser's DOM. <form action='loginScript.cgi' method="post" name="loginForm">
3
1497
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, not all the data gets reflected. In the form I have the following Javascript include: <script language="JavaScript1.2" src="$filename"
6
1710
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 MySQL database to get my resuts and return an ALERT box to the user if his form input was invalid. Problem is, I do not want to change the screen. I just want the dialog to pop up. I am very good at Perl, but I'm less than a novice at
10
2028
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 HTML with it and just call a CSS to do all the design work. JavaScript = ?? (I'm really not sure what to put -- AJAX??) Help me out folks, I'm new at this..
2
1218
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: <html> <p>Test</p> <p> <form action="http://127.0.0.1/test.pl" method="POST"> <input type="text" name="textfield" value="Hi!">
2
4888
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 #!/ois/usr/bin/perl -w use strict; use CGI qw(:standard); my $cgi=new CGI; my $flg=0;
3
3915
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 javascript windows to say the field is not keyed into properly. However, when i convert this html(with javascript inside) into perl script, the perl script did not validate when i keyed incorrect data in the form and it straight away executed perl script...
0
9855
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10906
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10585
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9426
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7017
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5682
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5866
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4482
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3132
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.