如何在没有javascript的情况下做同样的事情? [英] How to do the same without javascript ?

查看:63
本文介绍了如何在没有javascript的情况下做同样的事情?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

已发布在comp.lang.javascript但未找到任何解决方案:-(

-


大家好,


不知道在哪里问我的问题,因为要走的路是包含在

本质上可能的答案本身......你会在下面更好地理解:


好​​吧,我有一个HTML页面,其中包含一个表单,其中一个选项组

提供了两种方式来提交文件内容:


- 第一种方式:textarea字段中的base64数据。

- 第二种方式:文件字段中本地文件的路径


所以为了达到这个目的,当用户点击这个选项组的复选框时,

a javascript代码设法创建和删除适当的表单字段。

这一直有效。


这是一个显示此切换的测试页面:

--------------------- -----------------------
http://yohannl.tripod.com/file_form_...m_switcher.htm


这里是页​​面的来源:

------------------------------------

< html>

< head>

< meta http-equiv =" Content-Type"含量=" 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 ="(在此处粘贴Base64数据)" ;;}

else {

elt = document.createElement(''input'');

elt.type =" file" ;;}

elt.id = id;

elt.name =" file" ;;

area.appendChild(elt);}

else { //删除字段

if(elt!= null){

area.removeChild(elt);}}}

< / script> ;

< / head>

< body>

< h3& gt;文件格式切换器< / h3>

< input type =" submit" value =" Submit">

< form id =" ftest"行动= QUOT; /bin/engine.pl" method =" post"

enctype =" multipart / form-data">

< input type =" radio"名称= QUOT;文件"值= QUOT; 0" onclick =" addrem

(''local'',0); addrem(''base64'',1);" Base64 Data< br>

< ; input type =" radio"名称= QUOT;文件"值= QUOT 1 QUOT; onclick =" addrem

(''base64'',0); addrem(''local'',1);" Local Path< br>< br>

< / form>

< / body>

< / html>


所以,我的问题是:

--------------------

有没有办法实现同样的目标(提交一个textarea或

文件字段)没有任何javascript(有些浏览器会禁用

javascript支持)?


知道这两个方式不应该同时可用(以避免

用户在第一个字段中粘贴base64数据并指示本地文件路径

在第二个字段中,两者都是):根据用户选择使用

选项复选框。


也许通过CSS,不知道。你有什么想法吗?

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 ?

推荐答案

Scripsit Asterbing:
Scripsit Asterbing:

已经发布在comp中.lang.javascript但找不到任何解决方案:-(
Already posted in comp.lang.javascript but not found any solution :-(



感谢您的单挑。


哦,那个是你的全部信息。其余的都是签名。嗯,不完全;

OE只是认为 - 而不是 - 是一个签名分隔符。无论如何,你似乎

有一个_bad_开始。

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重生,我猜想。

Young Wittgenstein reborn, I presume.


好​​吧,我有一个HTML页面,其中包含一个表格,其中一个选项组

提供了两种提交文件内容的方法:


- 第一种方式:textarea字段中的base64数据。

- 2nd way:文件字段$ b $中本地文件的路径b
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



为什么有人会使用base64替代方案?听起来毫无意义。 _Normal_

通过textarea提交可能有意义。


提交本地文件的路径比网络创作更糟糕;

它不仅无用,而且还是一种安全威胁。您如何期望web

服务器访问用户计算机的文件系统(如果有)?


如果您希望允许文件提交,使用< input type =" file" ...取代。它有很多

并发症,但这是唯一的方法。更多信息:
http:// www。 cs.tut.fi/~jkorpela/forms/file.html


-

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

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/


在文章< 17 ******************** @ reader1.news.saunalahti.fi>,
jk ****** @ cs.tut.fi 说...
In article <17********************@reader1.news.saunalahti.fi >,
jk******@cs.tut.fi says...

为什么有人会使用base64替代方案?听起来毫无意义。 _Normal_

通过textarea提交可能有意义。


提交本地文件的路径比网络创作更糟糕;

它不仅无用,而且还是一种安全威胁。您如何期望web

服务器访问用户计算机的文件系统(如果有)?


如果您希望允许文件提交,使用< input type =" file" ...取代。它有很多

并发症,但这是唯一的方法。更多信息:
http:// www。 cs.tut.fi/~jkorpela/forms/file.html



抱歉,我不是对我的问题的回复;-)我知道并且没有任何关于如何处理

服务器端收到的数据和文件字段值的问题。


我的问题是关于在客户端管理表单的方法:这是我的第一篇文章的副本

没有 - :


不知道在哪里问我的问题,因为要走的路还包括在

本质上可能的答案......你'下面会更好地理解:


好​​吧,我有一个HTML页面,其中包含一个表单,其中一个选项组

提供了两种方式来提交文件内容:


- 第一种方式:textarea字段中的base64数据。

- 第二种方式:文件字段中本地文件的路径


因此,要实现这一点,当用户点击此选项组的复选框时,

a javascript代码会设法创建和删除适当的表单字段。

到目前为止,这种方法运作良好。


这是一个显示此切换的测试页:
http://yohannl.tripod.com/file_form_...m_switcher.htm


这里是页面来源:

< html>

&l t; head>

< meta http-equiv =" Content-Type"含量=" 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 ="(在此处粘贴Base64数据)" ;;}

else {

elt = document.createElement(''input'');

elt.type =" file" ;;}

elt.id = id;

elt.name =" file" ;;

area.appendChild(elt);}

else { //删除字段

if(elt!= null){

area.removeChild(elt);}}}

< / script> ;

< / head>

< body>

< h3& gt;文件格式切换器< / h3>

< input type =" submit" value =" Submit">

< form id =" ftest"行动= QUOT; /bin/engine.pl" method =" post"

enctype =" multipart / form-data">

< input type =" radio"名称= QUOT;文件"值= QUOT; 0" onclick =" addrem

(''local'',0); addrem(''base64'',1);" Base64 Data< br>

< ; input type =" radio"名称= QUOT;文件"值= QUOT 1 QUOT; onclick =" addrem

(''base64'',0); addrem(''local'',1);" Local Path< br>< br>

< / form>

< / body>

< / html>


所以,我的问题是:

有没有办法实现同样的目标(提交textarea或

文件字段)没有任何JavaScript(一些浏览器将禁用

javascript支持)?


知道这两种方法不应该在同一时间可用(为了避免

用户粘贴base64数据)第一个字段AND表示本地文件路径

在第二个中,两个):根据用户选择使用

选项复选框中的一个或另一个。

也许通过CSS,不知道。你有什么想法吗?

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 ?


5月21日上午8:39,Asterbing< n ... @ thanks.comwrote:
On May 21, 8:39 am, Asterbing <n...@thanks.comwrote:

有没有办法实现同样的目标(提交textarea或

文件字段)没有任何javascript(某些浏览器将禁用

javascript支持)?
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) ?



我总是在表单中以保持简单的方式包含两个选项 -

愚蠢的方式,而不是尝试做任何聪明的事情添加和

根据用户选择丢弃内容。请参阅我的电子邮件

格式检查器:
http://mailformat.dan.info/tools/check.html


知道这两种方式不应该在同时(为了避免

用户在第一个字段中粘贴base64数据并指示本地文件路径

在第二个字段中,两者):根据用户的一个或另一个选择使用

选项复选框。
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.



用户有时做傻事,但这真的没什么大不了的。你可以

编程你的接收脚本忽略其中一个或另一个

两个如果它们都被给出,或者给出错误或警告信息

通知用户他们的输入不一致。你应该

总是有服务器端有效性检查,而不是像Javascript那样依赖客户端的东西。


-

Dan

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


这篇关于如何在没有javascript的情况下做同样的事情?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆