473,569 Members | 2,737 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

JavaScript function saveText() needs to Update the Perl array@BO_FO_EMA IL

My first time posting to clj , I have already read
http://jibbering.com/faq/#FAQ2_3 before posting.

javascript function in question:

saveText() is as follows:

function saveText( scroll_list, t_area, listToBeUpdated ) {
alert( listToBeUpdated .name );
// need to know which list to add the value in textarea back into
for(var i = 0; i < scroll_list.opt ions.length; i++) {
if( scroll_list.opt ions[i].selected == true ) {
scroll_list.opt ions[i].text = t_area.value;
break;
}
}
// push new value to the corresponding scrolling_list
// then use this scrolling_list to update the dummylist
if ( listToBeUpdated .name == "bo_fo_emai ls" ) {
// push ( \@BO_FO_EMAILS, t_area.value );
}
}

The webpage is produced with the following Perl code:
print $query->td(
$query->textarea(-name=>'BOFOEmai ls',
-onChange=>"save Text( this.form.bo_fo _emails,
this.form.BOFOE mails,
this.form.bo_fo _emails )"),
$query->p,
$query->button(-name=>'ADD',
-value=>'Confirm Modifications',
-onClick=>"move( index, this.form.BOFOE mails,
this.form.bo_fo _emails)"),
$query->button(-name=>'REMOVE',
-value=>'Edit Selected Entry',
-onClick=>"edit( this.form.bo_fo _emails,
this.form.BOFOE mails)"));

Basically, I am trying to remove scroll_list.opt ions[i].text from
@BO_FO_EMAILS and replace it with t_area.value.

Order of elements does matter in BO_FO_EMails. ie.
scroll_list.opt ions[i].text must be in the same relative position as
t_area.value in @BO_FO_EMAILS.
Problem:
push ( \@BO_FO_EMAILS, t_area.value );

gives a javascript error "Error on Page". How do I update @BO_FO_EMAILS
within the javascript function saveText()?

Jan 20 '06 #1
4 1415
On Fri, 20 Jan 2006, Lee wrote:
William said:

My first time posting to clj , I have already read
http://jibbering.com/faq/#FAQ2_3 before posting.

javascript function in question:

saveText() is as follows:

function saveText( scroll_list, t_area, listToBeUpdated ) {
alert( listToBeUpdated .name );
// need to know which list to add the value in textarea back into
for(var i = 0; i < scroll_list.opt ions.length; i++) {
if( scroll_list.opt ions[i].selected == true ) {
scroll_list.opt ions[i].text = t_area.value;
break;
}
}
// push new value to the corresponding scrolling_list
// then use this scrolling_list to update the dummylist
if ( listToBeUpdated .name == "bo_fo_emai ls" ) {
// push ( \@BO_FO_EMAILS, t_area.value );
}
}
Problem:
push ( \@BO_FO_EMAILS, t_area.value );

gives a javascript error "Error on Page". How do I update @BO_FO_EMAILS
within the javascript function saveText()?


4. Your Perl code runs on the server, exits (typically), and then
the page is sent to the client computer where the browser
displays it and the user makes a selection. @BO_FO_EMAILS
doesn't exist at the time that they make a selection.


I hear that by the time I run my javascript, the perl script had already
existed. but the question becomes how do I update a server-side file with
the newest values retrieved by the javascript?

Jan 20 '06 #2

William wrote:
On Fri, 20 Jan 2006, Lee wrote:
4. Your Perl code runs on the server, exits (typically), and then
the page is sent to the client computer where the browser
displays it and the user makes a selection. @BO_FO_EMAILS
doesn't exist at the time that they make a selection.


I hear that by the time I run my javascript, the perl script had already
existed. but the question becomes how do I update a server-side file with
the newest values retrieved by the javascript?


You'll need to generate a new request from the client to the server
carrying your data, and then have the server-side script process it in
whatever way you need. Try researching XMLHttpRequest.

-- David

Jan 20 '06 #3
On Mon, 23 Jan 2006, William wrote:
On Fri, 20 Jan 2006, David Wahler wrote:

William wrote:
On Fri, 20 Jan 2006, Lee wrote:
4. Your Perl code runs on the server, exits (typically), and then
the page is sent to the client computer where the browser
displays it and the user makes a selection. @BO_FO_EMAILS
doesn't exist at the time that they make a selection.

I hear that by the time I run my javascript, the perl script had already
existed. but the question becomes how do I update a server-side file with
the newest values retrieved by the javascript?
You'll need to generate a new request from the client to the server
carrying your data, and then have the server-side script process it in
whatever way you need. Try researching XMLHttpRequest.


I am currently using XMLHttpRequest as follows:
function saveText( scroll_list, t_area, listToBeUpdated ) {
var updated = new Option();
updated.value = t_area.value;
updated.text = t_area.text;
for(var i = 0; i < scroll_list.opt ions.length; i++) {
if( scroll_list.opt ions[i].selected ) {
scroll_list.opt ions[scroll_list.sel ectedIndex].text =
updated.value;
scroll_list.opt ions[scroll_list.sel ectedIndex].value=
updated.value;
break;
}
}
var confirmReq;
var url = "http://mkmxg00/cgi/confirmUpload.p l";
confirmReq = new ActiveXObject( "Microsoft.XMLH TTP" );
confirmReq.onre adystatechange = processReqChang e;
confirmReq.open ( "POST", url, true );
confirmReq.send ( "" );

alert( url );
}

function processReqChang e() {
if ( confirmReq.read yState == 4 ) {
if ( confirmReq.stat us == 200 ) {
alert( "passed!" );
}
}
else {
alert( confirmReq.read yState + ", " + confirmReq.stat us );
}
}

Where http://mkmxg00/cgi/confirmUpload.pl is as follows:
#!/usr/bin/perl -w

#============== =============== =============== =============== =============== =====
# confirmUpload.p l
# once the user clicks "Confirm Modifications", this script picks up the
form's
# newest data from STDIN (POST method), then saves it to the dummylist
#============== =============== =============== =============== =============== =====

use CGI;
use CGI::Carp qw(fatalsToBrow ser);

my $query = new CGI;

# add code that reads in the "Confirm Modifications" request from the CGI
buffer
my $buffer;
read ( STDIN, $buffer, $ENV{'CONTENT_L ENGTH'} );

# buffer now contains data to be written to the dummylist
open ( OUTFD, "/mkapp/webapps/mxrt/data/extra_desk_tick ers.txt" ) or


The above line should read:
open ( OUTFD, ">/mkapp/webapps/mxrt/data/extra_desk_tick ers.txt" ) or
error("Couldn't open file: $DATAFILE\n");

But the same problem remained. any help is appreciated.
error("Couldn't open file: $DATAFILE\n");
print ( OUTFD $buffer );
close ( OUTFD );

exit 0;
My problem: nothing is written to
/mkapp/webapps/mxrt/data/extra_desk_tick ers.txt

I have already invoked confirmUpload.p l with the XMLHttpRequest confirmReq (I
am using IE 6.0 on Windows XP). Why does the file contains no output from
the CGI buffer?

Jan 23 '06 #4
On Fri, 20 Jan 2006, David Wahler wrote:

William wrote:
On Fri, 20 Jan 2006, Lee wrote:
4. Your Perl code runs on the server, exits (typically), and then
the page is sent to the client computer where the browser
displays it and the user makes a selection. @BO_FO_EMAILS
doesn't exist at the time that they make a selection.


I hear that by the time I run my javascript, the perl script had already
existed. but the question becomes how do I update a server-side file with
the newest values retrieved by the javascript?


You'll need to generate a new request from the client to the server
carrying your data, and then have the server-side script process it in
whatever way you need. Try researching XMLHttpRequest.


I am currently using XMLHttpRequest as follows:
function saveText( scroll_list, t_area, listToBeUpdated ) {
var updated = new Option();
updated.value = t_area.value;
updated.text = t_area.text;
for(var i = 0; i < scroll_list.opt ions.length; i++) {
if( scroll_list.opt ions[i].selected ) {
scroll_list.opt ions[scroll_list.sel ectedIndex].text = updated.value;
scroll_list.opt ions[scroll_list.sel ectedIndex].value= updated.value;
break;
}
}
var confirmReq;
var url = "http://mkmxg00/cgi/confirmUpload.p l";
confirmReq = new ActiveXObject( "Microsoft.XMLH TTP" );
confirmReq.onre adystatechange = processReqChang e;
confirmReq.open ( "POST", url, true );
confirmReq.send ( "" );

alert( url );
}

function processReqChang e() {
if ( confirmReq.read yState == 4 ) {
if ( confirmReq.stat us == 200 ) {
alert( "passed!" );
}
}
else {
alert( confirmReq.read yState + ", " + confirmReq.stat us );
}
}

Where http://mkmxg00/cgi/confirmUpload.pl is as follows:
#!/usr/bin/perl -w

#============== =============== =============== =============== =============== =====
# confirmUpload.p l
# once the user clicks "Confirm Modifications", this script picks up the form's
# newest data from STDIN (POST method), then saves it to the dummylist
#============== =============== =============== =============== =============== =====

use CGI;
use CGI::Carp qw(fatalsToBrow ser);

my $query = new CGI;

# add code that reads in the "Confirm Modifications" request from the CGI
buffer
my $buffer;
read ( STDIN, $buffer, $ENV{'CONTENT_L ENGTH'} );

# buffer now contains data to be written to the dummylist
open ( OUTFD, "/mkapp/webapps/mxrt/data/extra_desk_tick ers.txt" ) or
error("Couldn't open file: $DATAFILE\n");
print ( OUTFD $buffer );
close ( OUTFD );

exit 0;
My problem: nothing is written to
/mkapp/webapps/mxrt/data/extra_desk_tick ers.txt

I have already invoked confirmUpload.p l with the XMLHttpRequest confirmReq
(I am using IE 6.0 on Windows XP). Why does the file contains no output
from the CGI buffer?

Jan 23 '06 #5

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

Similar topics

2
12769
by: Obscurr | last post by:
i've got an array created in php that I want to send over to a javascript function. onclick = "return sjekk(<?echo $names; ?> )" in my "sjekk" function, when I try to print an alert : function sjekk(navn) { alert(navn); // or alert(navn) return(false);
7
21336
by: NotGiven | last post by:
I have a field called telephone whose ONBLUR action is to call a javascript function: validatePhoneNumber(telephone) The non-working function is: function validatePhoneNumber(v) { var phone =document.form. + v + .value; //HERE"S WHAT IS NOT WORKING
4
10671
by: Steven | last post by:
Hello, I have 3 files -- 1. mainform.aspx 2. mainform.aspx.cs 3. mouse.js mainform.aspx contains a image button ("zoominimgbut") which will exceute C# code, whenever the user clicks on it. mainform.aspx.cs is the code behind for mainform.aspx. Mouse.js contains javascript code which needs to executed
5
1704
by: mk | last post by:
Greetings all - im new to this newsgroup so pls dont flame me :p I need some help! Please view the html below in a browser. Or goto this url -http://firebrain.co.uk/java-problem.htm (Assuming you have seen the rendered code) Basically I need the X buttons to change all the values of each textbox to zero either in the col or row depending on...
1
7687
by: vocalise | last post by:
The title probably isn't very clear, but I haven't been able to find this problem (or I must be having problems figuring out which search strings to use) so I apologize if this has been addressed before, and I apologize if this is the wrong forum since I'm trying to use the XMLHTTPRequest with Javascript and PHP and I couldn't figure out which...
0
1216
by: kloppie | last post by:
Hi there, im using ASP.NET AJAX to update a GridView, using the UpdatePanel and the Timer. What I would like is to update a Label on the page with the last time of update. But it should be the time on the users computer and not the time on the server. Therefore i need to have a javascript function update the label for me, but i cant find a...
2
4654
by: Anees | last post by:
Hi, i need to invoke a javascript function while clicking a button that is in a flash movie. i hav used geturl() to redirect the page to some other page. but is it possible to call a javascript function from FLASH..?? please help me Regards
10
6125
by: getmadhu | last post by:
Hi All, How can i pass a Perl var($val) as a parameter to a Javascript function. Please can any one help me out... ex: Perl Code ---------------- $var = 'sample'
3
2297
by: pinko1204 | last post by:
My Update function cannot successful update to sql table even don't have any error. Please help to check .....thx PHP1 <?php require_once 'header.php'; ?> <style type="text/css"> <!--
0
7700
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...
0
7614
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8125
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...
1
7676
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7974
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6284
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...
0
3642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1221
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
938
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...

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.