How to do this without javascript ?

A

Asterbing

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_switcher/file_form_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 ?
 
V

VK

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

That is not a reason to re-post the same every few days. Wait for more
answers in the original thread.

Overall is it some late springtime trend? "- How to use Javascript
without using native Javascript tools?" (Rebekka), "- Hey, Javascript
programmers, how to avoid Javascript?" (Asterbing)
:) :-|

1) Make two separate HTML pages with forms, load one page by default
but provide a link on each page so user could load this or that form
depending on her choice.

2) Ask comp.infosystems.www.authoring.stylesheets is they have some
creative ideas about pseudo-element usage :)visited, :active, :hover
etc). Bearing in mind IE6 limited support for that I would avoid it if
possible.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top