El caso es que para esto quize empesar a aprender a trabajar con objetos
y pues con lo poco que me aprendi en http://www.desarrolloweb.com/articul....php?manual=26 todo me andaba de maravilla pero bueno derrepente No se porque mi propiedad pierde el valor asignado anteriormente ya no se que hacer os paso el code para que vean por donde va la cosa hojala los alguien de ustedes me pueda ayudar gracias...
Código:
_Saludos... <html>
<head>
<title>Prueba Post</title>
<script type="text/javascript">
var agrCodes = new Array('[b ]','[/b ]','[i ]','[/i ]','[u ]','[/u ]');
function imprimete() {
alert(this.sCloseCode);
}
function saberName() {
this.inputname = this.openCode.replace('[','')
this.inputName = this.inputname.replace('/','')
this.inputName = this.inputname.replace(']','')
}
function saberValue() {
this.inputValue = eval('window.document.formu.'+this.inputName+'.value')
}
function resultadoInputV() {
this.resultInputValue = this.inputValue.indexOf('*')
}
function cambia_insertaNum() {
this.sIndice = this.indice.toString
this.lonIndice = this.sIndice.length
if(this.lonIndice == 2) {
this.sCloseCode += this.indice
} else {
this.sCloseCode += 0
this.sCloseCode += this.indice
}
}
function cambiaValue() {
if(this.resultInputValue == -1) {
eval('window.document.formu.'+this.inputName+'.value="'+this.inputName.toUpperCase()+'*"')
} else {
eval('window.document.formu.'+this.inputName+'.value="'+this.inputName.toUpperCase()+' "')
}
}
function insertaValue() {
if(this.resultInputValue == -1) {
window.document.formu.mensaje.value = window.document.formu.mensaje.value + this.openCode
window.document.formu.mensaje.focus()
} else {
window.document.formu.mensaje.value = window.document.formu.mensaje.value + this.closeCode
window.document.formu.mensaje.focus()
}
}
function InsertCode(numero) {
this.indice = numero
this.sIndice = null
this.lonIndice = null
this.openCode = agrCodes[numero]
this.closeCode = agrCodes[numero + 1]
this.inputName = null
this.inputValue = null
this.resultInputValue = null
this.sCloseCode = null
// Metodos.
this.saberName = saberName
this.saberValue = saberValue
this.resultadoInputV = resultadoInputV
this.cambiaValue = cambiaValue
this.insertaValue = insertaValue
this.cambia_insertaNum = cambia_insertaNum
this.imprimete = imprimete//solo para comprobar el valor de mis atributos.
}
// Funcion paa accionar el Objeto.
function accionar(num) {
var miObjeto = new InsertCode(num);
miObjeto.saberName();miObjeto.saberValue();miObjeto.resultadoInputV();
if(miObjeto.resultInputValue == -1) {
miObjeto.cambiaValue();
miObjeto.insertaValue();
miObjeto.cambia_insertaNum();
miObjeto.imprimete();
} else {
miObjeto.cambiaValue();
miObjeto.insertaValue();
miObjeto.imprimete();
}
}
</script>
</head>
<body>
<center>
<form name="formu">
<input type="button" name="b" value="B " onclick="accionar(0)">
<input type="button" name="i" value="I " onclick="accionar(2)">
<input type="button" name="u" value="U " onclick="accionar(4)">
<br><br>
<input type="button" name="alerta" value="alertar" onclick="accionar(0)">
<br><br>
<textarea name="mensaje" cols="30" rows="10"></textarea>
</form>
</center>
</body>
</html>

