473,321 Members | 1,748 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,321 software developers and data experts.

How to do the same without javascript ?

Already posted in comp.lang.javascript but not found any solution :-(
--

Hi all,

Don't know where to ask my question because the way to go is included in
the possible answer itself by nature... You'll understand better below :

Well, I have an HTML page containing a form in which an options group
provides two ways to submit content of a file :

- 1st way : base64 data in a textarea field.
- 2nd way : path to local file in a file field

So, to achieve this, when user click on a checkbox of this option group,
a javascript code manages to create and remove appropriated form fields.
And this works well until now.

Here is a test page showing this switching :
--------------------------------------------
http://yohannl.tripod.com/file_form_...m_switcher.htm

And here is the source of the page :
------------------------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function addrem(id,op)
{
var area = document.getElementById('ftest');
var elt = document.getElementById(id);

if (op == 1){ // add field
if (elt != null){
return;}
if (id == "base64"){
elt = document.createElement('textarea');
elt.cols = "60";
elt.rows = "10";
elt.value = "(paste Base64 data here)";}
else {
elt = document.createElement('input');
elt.type = "file";}
elt.id = id;
elt.name = "file";
area.appendChild(elt);}
else { // remove field
if (elt != null){
area.removeChild(elt);}}}
</script>
</head>
<body>
<h3>File Form Switcher</h3>
<input type="submit" value="Submit">
<form id="ftest" action="/bin/engine.pl" method="post"
enctype="multipart/form-data">
<input type="radio" name="file" value="0" onclick="addrem
('local',0);addrem('base64',1);"Base64 Data<br>
<input type="radio" name="file" value="1" onclick="addrem
('base64',0);addrem('local',1);"Local Path<br><br>
</form>
</body>
</html>

So, my question is :
--------------------
Is there a way to achieve this same objective (submit a textarea or a
file field) without any javascript (some browsers will have disabled
javascript support) ?

Knowing the two ways shouldn't be available in the same time (to avoid
user pastes a base64 data in first field AND indicates a local file path
in the second one, both) : one or another according to user choice using
option checkboxes.

Maybe through CSS, don't know. Do you have an idea ?
May 21 '07 #1
15 2256
Scripsit Asterbing:
Already posted in comp.lang.javascript but not found any solution :-(
Thanks for the heads-up.

Oh, that was your entire message. The rest is a signature. Well, not quite;
OE just thinks that "--" and not "-- " is a sig separator. Anyway, you seem
to have a _bad_ start.
because the way to go is included in the possible answer itself by nature
Young Wittgenstein reborn, I presume.
Well, I have an HTML page containing a form in which an options group
provides two ways to submit content of a file :

- 1st way : base64 data in a textarea field.
- 2nd way : path to local file in a file field
Why would anyone use the base64 alternative? Sounds pointless. _Normal_
submission via a textarea might make sense.

Submitting a path to a local file is worse than pointless in web authoring;
it is not just useless, it's also a security threat. How do you expect a web
server to access the user computer's file system, if it has one?

If you wish allow file submissions, use <input type="file" ...>. It has many
complications, but it's the only way. More info:
http://www.cs.tut.fi/~jkorpela/forms/file.html

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

May 21 '07 #2
In article <17********************@reader1.news.saunalahti.fi >,
jk******@cs.tut.fi says...
Why would anyone use the base64 alternative? Sounds pointless. _Normal_
submission via a textarea might make sense.

Submitting a path to a local file is worse than pointless in web authoring;
it is not just useless, it's also a security threat. How do you expect a web
server to access the user computer's file system, if it has one?

If you wish allow file submissions, use <input type="file" ...>. It has many
complications, but it's the only way. More info:
http://www.cs.tut.fi/~jkorpela/forms/file.html
Sorry, but i's not a reply to my question ;-) I know and haven't any
problem about how to handle both data and file fields values received on
server-side.

My question was about way to manage form on client side : here is a copy
of my first post without the "--" :

Don't know where to ask my question because the way to go is included in
the possible answer itself by nature... You'll understand better below :

Well, I have an HTML page containing a form in which an options group
provides two ways to submit content of a file :

- 1st way : base64 data in a textarea field.
- 2nd way : path to local file in a file field

So, to achieve this, when user click on a checkbox of this option group,
a javascript code manages to create and remove appropriated form fields.
And this works well until now.

Here is a test page showing this switching :
http://yohannl.tripod.com/file_form_...m_switcher.htm

And here is the source of the page :
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function addrem(id,op)
{
var area = document.getElementById('ftest');
var elt = document.getElementById(id);

if (op == 1){ // add field
if (elt != null){
return;}
if (id == "base64"){
elt = document.createElement('textarea');
elt.cols = "60";
elt.rows = "10";
elt.value = "(paste Base64 data here)";}
else {
elt = document.createElement('input');
elt.type = "file";}
elt.id = id;
elt.name = "file";
area.appendChild(elt);}
else { // remove field
if (elt != null){
area.removeChild(elt);}}}
</script>
</head>
<body>
<h3>File Form Switcher</h3>
<input type="submit" value="Submit">
<form id="ftest" action="/bin/engine.pl" method="post"
enctype="multipart/form-data">
<input type="radio" name="file" value="0" onclick="addrem
('local',0);addrem('base64',1);"Base64 Data<br>
<input type="radio" name="file" value="1" onclick="addrem
('base64',0);addrem('local',1);"Local Path<br><br>
</form>
</body>
</html>

So, my question is :
Is there a way to achieve this same objective (submit a textarea or a
file field) without any javascript (some browsers will have disabled
javascript support) ?

Knowing the two ways shouldn't be available in the same time (to avoid
user pastes a base64 data in first field AND indicates a local file path
in the second one, both) : one or another according to user choice using
option checkboxes.

Maybe through CSS, don't know. Do you have an idea ?
May 21 '07 #3
Dan
On May 21, 8:39 am, Asterbing <n...@thanks.comwrote:
Is there a way to achieve this same objective (submit a textarea or a
file field) without any javascript (some browsers will have disabled
javascript support) ?
I've always just included both options on the form in a keep-it-simple-
stupid way, without trying to do anything "clever" with adding and
dropping stuff based on user choices. See for instance my e-mail
format checker:
http://mailformat.dan.info/tools/check.html
Knowing the two ways shouldn't be available in the same time (to avoid
user pastes a base64 data in first field AND indicates a local file path
in the second one, both) : one or another according to user choice using
option checkboxes.
Users do silly things sometimes, but it's really no big deal; you can
either program your receiving script to ignore one or the other of the
two if they're both given, or else give an error or warning message
notifying the user that their input was inconsistent. You should
always have server-side validity checking anyway, rather than relying
on client-side stuff like Javascript.

--
Dan

May 21 '07 #4
Scripsit Asterbing:
Sorry, but i's not a reply to my question ;-)
This isn't a helpdesk, and this is a discussion group about HTML authoring
for the World Wide Web.
My question was about way to manage form on client side
That's not something you do in HTML.

If you really know what you are doing server-side, then you don't have any
problem as long as you simply include two alternatives - a form field and a
textarea - into the HTML form. If you wish to get help with _creating_ some
problems client-side, you need to ask for help elsewhere.
here is a copy of my first post without the "--" :
Are you trying to get plonked or what?

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

May 21 '07 #5
In article <11**********************@z28g2000prd.googlegroups .com>,
da*@tobias.name says...
I've always just included both options on the form in a keep-it-simple-
stupid way, without trying to do anything "clever" with adding and
dropping stuff based on user choices. See for instance my e-mail
format checker:
http://mailformat.dan.info/tools/check.html
Effectively, seen your form (thanks), but I'm in another case because in
some case (I know, a lot of constraint), the base64 field will be pre-
filled and user will have choice to acdept it or use the file filed to
submit something different : so, I don't think user will think (or even
want to spend any seconds for this in spite of warning) to erase the
textarea content.
>
Users do silly things sometimes, but it's really no big deal; you can
either program your receiving script to ignore one or the other of the
two if they're both given, or else give an error or warning message
notifying the user that their input was inconsistent. You should
always have server-side validity checking anyway, rather than relying
on client-side stuff like Javascript.
Yes, but to be totally complete, I have to say I'm not in charge of
server-side and I have to do my best to provide the most filtered as
possible things using client-side possibilities : complex, isn't it ?
;-)
May 21 '07 #6
In article <Gi********************@reader1.news.saunalahti.fi >,
jk******@cs.tut.fi says...
This isn't a helpdesk, and this is a discussion group about HTML authoring
for the World Wide Web.
HTML and all arounbd, I guess
My question was about way to manage form on client side

That's not something you do in HTML.
I don't know the reply and this because of that I'm asking the question
;-)
If you really know what you are doing server-side, then you don't have any
problem as long as you simply include two alternatives - a form field and a
textarea - into the HTML form.
I'm not in charge of the server-side in the project and this is the
corner of the problem : I have to solve this on client-side.
If you wish to get help with _creating_ some
problems client-side, you need to ask for help elsewhere.
Just indicate me the right newsgroup and I'll go without delay ;-) The
probvlem is that it depend of the way of solution : according to your
opinion, should I put my question in a group about CSS, javascript (I
want to strip-out js), HTML (maybe alt.html ?), general authoring...
Where ?
May 21 '07 #7
Scripsit Asterbing:
>This isn't a helpdesk, and this is a discussion group about HTML
authoring for the World Wide Web.

HTML and all arounbd, I guess
You guessed wrong. How about checking some facts? The newsgroup descriptions
aren't really top secret documents.
I'm not in charge of the server-side in the project and this is the
corner of the problem : I have to solve this on client-side.
So did you previously lie when you wrote: "I know and haven't any
problem about how to handle both data and file fields values received on
server-side"? If there are no problems there, then you don't have to solve
"this" on client-side.

Besides, if you had to solve this on client-side, then there is no solution
for you. Just because you need to invent a perpetuum mobile doesn't make it
possible.
Just indicate me the right newsgroup and I'll go without delay ;-)
This isn't a helpdesk for finding a group. So far, you conduct has been
disruptive, so I don't suggest any group before you have thought about the
issue, considered the responses you have got and studied some Usenet
behavior (or "netiquette") guidelines.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

May 21 '07 #8
Asterbing wrote:
I'm not in charge of the server-side in the project and this is the
corner of the problem : I have to solve this on client-side.
For some tasks, you need to collaborate. Surely your server-side people
realize this.

--
-bts
-Motorcycles defy gravity; cars just suck
May 21 '07 #9
In article <Qp*********************@reader1.news.saunalahti.f i>,
jk******@cs.tut.fi says...
Scripsit Asterbing:

You guessed wrong. How about checking some facts? The newsgroup descriptions
aren't really top secret documents.
Just some ten thousands of ng to check, as you say.
So did you previously lie when you wrote: "I know and haven't any
problem about how to handle both data and file fields values received on
server-side"? If there are no problems there, then you don't have to solve
"this" on client-side.
I have not any problem in server-side because of two things : 1) it's
not my job 2) the ones who work on this already handle the base64 case
and the file field one. My job is just to provide one or another, not
both.
Besides, if you had to solve this on client-side, then there is no solution
for you. Just because you need to invent a perpetuum mobile doesn't make it
possible.
A little bit restrictive reply, isn't it. If you don't have any positive
element to transmit here, why reply ? Are you in charge of something
special in this ng ?
Just indicate me the right newsgroup and I'll go without delay ;-)

This isn't a helpdesk for finding a group. So far, you conduct has been
disruptive, so I don't suggest any group before you have thought about the
issue, considered the responses you have got and studied some Usenet
behavior (or "netiquette") guidelines.
And it's not the Yucca's group !
May 22 '07 #10
In article <QE*******************@bgtnsc04-news.ops.worldnet.att.net>,
a.*********@example.invalid says...
Asterbing wrote:
I'm not in charge of the server-side in the project and this is the
corner of the problem : I have to solve this on client-side.

For some tasks, you need to collaborate. Surely your server-side people
realize this.

Yes, you're right, but it's a matter of deadline : even if we'll succeed
to collaborate, the fact is that we're not "synchro" just now.
May 22 '07 #11
rf
"Asterbing" <no@thanks.comwrote in message
news:MP************************@news.tiscali.fr...
In article <QE*******************@bgtnsc04-news.ops.worldnet.att.net>,
a.*********@example.invalid says...
>Asterbing wrote:
I'm not in charge of the server-side in the project and this is the
corner of the problem : I have to solve this on client-side.

For some tasks, you need to collaborate. Surely your server-side people
realize this.


Yes, you're right, but it's a matter of deadline : even if we'll succeed
to collaborate, the fact is that we're not "synchro" just now.
Let me see...

You have a textarea which may or may not contain data.

You have a <input type="file"which may or may not contain a file name,
which will be uploaded.

You want one, and only one, of them to be sent to the server. Correct?

If, as you state, javascript is not available then you do not have any
control over this. If both input fields are "successfull" then both will be
sent to the server. That is how browsers work. End of story. Go over to the
specifications and read up on how input fields become "successfull", and how
they are sent to the server when they are.

As Beauregard implies, it is time to tell your supervisor/boss that this
simply can - not - be - done. You will NOT solve this client side.

Have it fixed it server side.
--
Richard.
May 22 '07 #12
rf wrote:
As Beauregard implies, it is time to tell your supervisor/boss that this
simply can - not - be - done. You will NOT solve this client side.
Hmmm. Let's think about this a moment or so...

<form>
[HTML-by-JavaScript]
<noscript>
<p>GO AWAY! You can't use this form, you silly person!</p>
</noscript>
</form>

There ya go. Problem solved. To hell with the 10% who won't be able to
use it.

--
-bts
-posting complete; remove tongue from cheek
May 22 '07 #13
Beauregard T. Shagnasty wrote:
rf wrote:
>As Beauregard implies, it is time to tell your supervisor/boss that this
simply can - not - be - done. You will NOT solve this client side.

Hmmm. Let's think about this a moment or so...

<form>
[HTML-by-JavaScript]
<noscript>
<p>GO AWAY! You can't use this form, you silly person!</p>
</noscript>
</form>
LOL!

To OP: In case you haven't gotten the message here is the mantra "Never
rely on client-side for 'mission critical' operations, it is the role of
server-side". Now repeat 100 times or until you "get it". If it is your
boss that insists, then print this out and have him recite the mantra
until he "gets it".

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
May 22 '07 #14
rf <rf@invalid.comwrote:
You have a textarea which may or may not contain data.

You have a <input type="file"which may or may not contain a file name,
which will be uploaded.

You want one, and only one, of them to be sent to the server. Correct?

If, as you state, javascript is not available then you do not have any
control over this. If both input fields are "successfull" then both will be
sent to the server. That is how browsers work. End of story. Go over to the
specifications and read up on how input fields become "successfull", and how
they are sent to the server when they are.

As Beauregard implies, it is time to tell your supervisor/boss that this
simply can - not - be - done. You will NOT solve this client side.
Maybe I missed something. Is there a reason the OP can't have two separate
forms, one with the textarea and one with the <input type="file">? Naive
users can submit only one form's data at a time, regardless of whether
JavaScript is available/enabled.

Malicious users can still submit whatever they like to the server-side
program, but they could do that before.
--
Darin McGrew, mc****@stanfordalumni.org, http://www.rahul.net/mcgrew/
Web Design Group, da***@htmlhelp.com, http://www.HTMLHelp.com/

"Advice is what you ask for when you know the answer but wish you didn't."
May 22 '07 #15
So, In article <f2**********@blue.rahul.net>, mc****@stanfordalumni.org
says...
Maybe I missed something. Is there a reason the OP can't have two separate
forms, one with the textarea and one with the <input type="file">?
Good idea and I thinbk it's the way I'll go in final and awaiting stuff
go beyond on server-side.

Then, imagining two forms (first with the textarea and the second with a
file field), it remains a last problem. What about the "common" fields ?
Yes, because, in my test page, there'are not all the fields. So, in
real, there are checkboxes and input text...

Is there a way, awaiting WebForm 2 which will provide this : "All form
controls as well as the fieldset element may have the form attribute
specified. The form attribute gives a space-separated list of IDs of
form elements that the form control is to be associated with, and
overrides the relationship between the form control and any ancestor
form element.", extract of point 2.8 at http://www.whatwg.org/specs/web-
forms/current-work/
May 22 '07 #16

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

Similar topics

4
by: Caroline | last post by:
Rather than opening a new window, how can I add a text (or HTML code) in the same HTML page, in a specific location? The code I tried is the following: <head> <script language="JavaScript">...
2
by: Jeff | last post by:
I'm trying to create a dynamic form that can have multiple groups of radio buttons (each group has two buttons) with the same name. Essentially, the form allows a user to enter as many names as...
1
by: Jenny | last post by:
Hi, Can I create an array of tags by assigning same name to these tags? For example, I have two <p> tags with the same name t1. But document.all.b.value=document.all.t.length does not...
2
by: eels | last post by:
Hello, I want to open a new window with javascript: secondWindow=window.open(...) secondWindow.document.writeln(...) I wrote the javascript code into a separate file secondwindow.js. I...
5
by: Michelle Stone | last post by:
Hi everybody I am writing a simple asp.net application using form authentication. I store the list of all users and their passwords in an SQL Server database table. My client recently told me...
3
by: William F. Robertson, Jr. | last post by:
My problem is I routinely use both vbscript and javascript (yes, that is a problem in itself) on the same webpage. I feel placing the "javscript:" or "vbscript:" on all my client side events is...
13
by: Jim Carlock | last post by:
I have over a hundred pictures I would like to present. Is it practical to create and parse an array of pictures, picture paths, et al using server-side scripting to accomplish this? I...
3
by: Beholder | last post by:
I hope that someone can help me with the following: Short background explenation: I have a shrfepoint page (newform.aspx) in a item list. On this page is a lookup column that displays a lookup...
7
by: Tony Girgenti | last post by:
Hello. I'm trying to undetrstand ASP.NET 2.0 and javascript. When i have a button and i click on it and i see the web broswer progress bar at the bottom do something, does that mean that there...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.