Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/06/2009, 13:44
luqueagm
 
Fecha de Ingreso: junio-2009
Mensajes: 101
Antigüedad: 14 años, 11 meses
Puntos: 0
formulario a un archivo en 'txt'

Hola..soy nuevo

Mira. Tengo un codigo que estoy desarrollando pero no sé porque no me da una funcion de javascript el resultado que deberia dar. Se trata de enviar los valores de un formulario a un archivo en 'txt'. Lo voy a utilizar solo en un computador (no para internet) y en explorer. PEro en relacion al codigo en javascript no lo hace y no sé por qué. HE aqui el codigo:

----
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0013)about:internet --><HTML><HEAD><TITLE>prueba.xls</TITLE>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<META content="Microsoft FrontPage 5.0" name=GENERATOR>
<STYLE type=text/css>.eebuttons {
WIDTH: 120px
}
.ee100 {
PADDING-RIGHT: 1px; PADDING-LEFT: 1px; FONT-WEIGHT: 400; FONT-SIZE: 10pt; VERTICAL-ALIGN: bottom; COLOR: windowtext; PADDING-TOP: 1px; FONT-STYLE: normal; FONT-FAMILY: Arial; TEXT-ALIGN: left
}
.ee103 {
PADDING-RIGHT: 1px; PADDING-LEFT: 0px; FONT-WEIGHT: 400; FONT-SIZE: 10pt; BACKGROUND: silver; VERTICAL-ALIGN: bottom; COLOR: windowtext; PADDING-TOP: 0px; FONT-STYLE: normal; FONT-FAMILY: Arial; TEXT-ALIGN: right
}
.ee105 {
FONT-WEIGHT: 400; FONT-SIZE: 10pt; BACKGROUND: silver; VERTICAL-ALIGN: bottom; COLOR: windowtext; FONT-STYLE: normal; FONT-FAMILY: Arial; TEXT-ALIGN: right
}
TEXTAREA {
OVERFLOW: auto
}
</STYLE>

<STYLE type=text/css media=screen>.eebuttonbar_top {
MARGIN-BOTTOM: 6px; PADDING-BOTTOM: 6px; BORDER-BOTTOM: blue 2px solid
}
.eebuttonbar_bottom {
BORDER-TOP: blue 2px solid; MARGIN-TOP: 6px; PADDING-TOP: 6px
}
.eetabs {
DISPLAY: block
}
</STYLE>

<STYLE type=text/css media=print>.eebuttonbar_top {
DISPLAY: none
}
.eebuttonbar_bottom {
DISPLAY: none
}
.eetabs {
DISPLAY: none
}
</STYLE>

<SCRIPT language=javascript>


var co = new Object;
function recalc_onclick(ctl) {
if (true) {


co.p1A2=eeparseFloat(document.formc.p1A2.value);co .p1B2=eeparseFloat(document.formc.p1B2.value);calc (co);document.formc.p1C2.value=eedisplayFloat(co.p 1C2);
};};


var eeisus=0;var eetrue="VERDADERO";var eefalse="FALSO";var eedec=",";var eeth=".";var eedecreg=new RegExp(",","g");var eethreg=new RegExp("[.]","g");

function calc(data){var c1A2=data.p1A2;var c1B2=data.p1B2;var c1C2=(((c1A2)+(c1B2)));data.p1C2=c1C2;};

function myIsNaN(x){return(isNaN(x)||(typeof x=='number'&&!isFinite(x)));};function eeparseFloat(str){str=String(str).replace(eedecreg ,".");var res=parseFloat(str);if(isNaN(res)){return 0;}else{return res;}};function eedisplayFloat(x){if(myIsNaN(x)){return Number.NaN;}else{return String(x).replace(/\./g,eedec);}};
</SCRIPT>


<!-- ejemplo Header end --></HEAD>
<BODY onload=initial_update();document.formc.p1A2.focus( );>

<script language="javascript">
function Writedata()
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var write_id;
write_id = document.formc.getElementById('write_id').value ;
alert('El archivo ha sido realizado \n' + write_id);
var s = fso.CreateTextFile(write_id, true);

s.WriteLine(document.formc.getElementById('p1A2'). value);
s.WriteLine(document.formc.getElementById('p1B2'). value);
s.WriteLine(document.formc.getElementById('p1C2'). value);
s.Close();
}
</script>


<!-- ejemplo Body start -->
<FORM id=formc name=formc action="" method=post>
<DIV class=eebuttonbar_top>


</DIV>
<DIV id=panel1 style="DISPLAY: block">
<TABLE style="WIDTH: 180pt; BORDER-COLLAPSE: collapse" cellSpacing=0
cellPadding=0 bgColor=#ffffff border=0>
<COLGROUP>
<COL width=60>
<COL width=60>
<COL width=60>
<TBODY>
<TR style="HEIGHT: 13pt">
<TD class=ee100>&nbsp; </TD>
<TD class=ee100>&nbsp; </TD>
<TD class=ee100>&nbsp; </TD></TR>
<TR style="HEIGHT: 13pt">
<TD class=ee103>
<INPUT class=ee105 id=p1A2
onblur="this.value=eedisplayFloat(eeparseFloat(thi s.value));recalc_onclick('p1A2')"
style="WIDTH: 100%" tabIndex=1 value=2 name=p1A2 size="20"> </TD>
<TD class=ee103>
<INPUT class=ee105 id=p1B2
onblur="this.value=eedisplayFloat(eeparseFloat(thi s.value));recalc_onclick('p1B2')"
style="WIDTH: 100%" tabIndex=2 value=2 name=p1B2 size="20"> </TD>
<TD class=ee103>
<INPUT class=ee105 id=p1C2
style="BORDER-RIGHT: #000000 0px solid; BORDER-TOP: #000000 0px solid; OVERFLOW: hidden; BORDER-LEFT: #000000 0px solid; WIDTH: 100%; BORDER-BOTTOM: #000000 0px solid"
tabIndex=-1 readOnly value=0 name=p1C2 size="20"> </TD></TR></TBODY></TABLE>
<P></P></DIV>
<DIV class=eebuttonbar_bottom><INPUT class=eebuttons onclick="recalc_onclick('')" type=button value=CALCULAR name=xl_update_bottom>
<INPUT class=eebuttons onclick="reset_onclick('')" type=button value=BORRAR name=xl_reset_bottom>
<INPUT class=eebuttons onclick=window.print(); type=button value=IMPRIMIR name=xl_print_bottom>


<b><input type="button" onclick="Writedata()" value="ARCHIVO TXT">
<input type="text" name="write" value="Computos.txt" id="write_id" size="20"><br/></b>

</DIV>

<SCRIPT language=javascript>
function reset_onclick(x){document.formc.reset();postcode() ;recalc_onclick('');};function postcode(){};function eequerystring(){var querystring=document.location.search;if(querystrin g.length>0){variables=(querystring.substring(1)).s plit("&");var variable;var key;var value;for(var ii=0;ii<variables.length;ii++){variable=variables[ii].split("=");key=unescape(variable[0]);value=unescape(variable[1]);if(document.formc[key]!=null){document.formc[key].value=value;}}}}function initial_update(){postcode('');eequerystring();reca lc_onclick('');}
</SCRIPT>
</FORM><!-- ejemplo Body end --></BODY></HTML>


-----

Lo esencial del codigo que no funciona esta aqui:


<!-- ejemplo Header end --></HEAD>
<BODY onload=initial_update();document.formc.p1A2.focus( );>

<script language="javascript">
function Writedata()
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var write_id;
write_id = document.formc.getElementById('write_id').value ;
alert('El archivo ha sido realizado \n' + write_id);
var s = fso.CreateTextFile(write_id, true);

s.WriteLine(document.formc.getElementById('p1A2'). value);
s.WriteLine(document.formc.getElementById('p1B2'). value);
s.WriteLine(document.formc.getElementById('p1C2'). value);
s.Close();
}
</script>

...y en...


<b><input type="button" onclick="Writedata()" value="ARCHIVO TXT">
<input type="text" name="write" value="Computos.txt" id="write_id" size="20"><br/></b>

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

Agradezco su ayuda.

Luque