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 ?