By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,738 Members | 1,480 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,738 IT Pros & Developers. It's quick & easy.

Passing a variable's value from javascript to a perl script

P: n/a
Hi,

I have a text-area which contains values from mysql database and 2
buttons, Edit and Update.
When I click on the Edit button, I can edit the text-area
(initially non-editable).
After this, if I click on the Update button, the values in the
text-area must be updated in the mysql database.
I am storing the values of the text-area in a variable. I am using
javascript to pass the variable.
How do I pass this variable to a Perl script and how do I recieve
that variable in that script?

Please help me!!!

Sep 4 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
ASM
En réponse à sa********@gmail.com qui écrivit, en date du : 4/09/07
11:40, le message suivant :
(...)
I am storing the values of the text-area in a variable. I am using
javascript to pass the variable.
Why ?
The form can't send this by itself ?
How do I pass this variable to a Perl script and how do I recieve
that variable in that script?
It is a PHP question, no ?
(or an asp question ...)

<form action="myFile.asp" method="post">
<textarea name="content" ...></textarea>
<button ....>Edit</button>
<input type=submit value="Save">
</form>

And with multiple textareas

<form action="myFile.asp" method="post">
<p>Infos 1 :
<textarea name="Text_1" ...></textarea>
<button ....>Edit</button>
<input name="save" type=submit value="Save info 1">
</p>
<p>Infos 2 :
<textarea name="Text_2" ...></textarea>
<button ....>Edit</button>
<input name="save" type=submit value="Save info 2">
</p>
<p>Infos 3 :
<textarea name="Text_3" ...></textarea>
<button ....>Edit</button>
<input name="save" type=submit value="Save info 3">
</p>
<p><input name="save" type=submit value="Save all"></p
</form>

The variables 'content'
or 'T_1' 'S_1' 'T_2' 'S_2' 'T_3' 'S_3'
are sent with their values
your asp (or php) has to analyze these couples variable+value

If you absolutly want to sent both to php and to perl

<form action="myFile.php" method="post"
onsubmit="return aspJS(this);">
<script type="text/javascript">
function aspJS() {
var url=[], f = this.elements;
for(var i=0; i<f.length; i++)
if(f[i].type=='textarea' && !f[i].disabled)
url[url.length] = f[i].name+'='+f[i].value;
if(url.length<1) {
alert('no change !');
return false;
}
setTimout(function() {
location.href = 'myFile.asp?'+url.join('&');
},10);
return true;
}
</script>

*if JS is enabled* that would call your asp and post the form to php
but ... what about disabled JS ?

--
Sep 4 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.