Click to See Complete Forum and Search --> : Trouble with TEXT values when moving to another field


Caliban
02-24-2003, 09:44 AM
Hi folx,
I'm using this piece of code, to send the form data:

==================================
function Send_Form(form){
for (i=1; i< document.getElementById('Tabla_Estudios').rows.length;i++){
for (j=1;j<=6;j++){
var objInput1 = document.createElement("INPUT");
objInput1.type = "HIDDEN";
objInput1.name = "Careers"+i+j;
objInput1.value = document.getElementById('celda'+i+j).valor;
form.appendChild(objInput1);
}
}
form.submit();
}
==================================
There's an input field, type "TEXT".
The value of document.getElementById('celda'+i+j).valor
(when j=5) is "Systems Engineering",
but when I move this value to the variable "objInput1.value"
it only takes "Systems" and ignores the rest of the field value.

It only occurs when the field type is TEXT, in the other cases it works fine.

How could I fix this issue?

TIA and best regards,
Caliban

Phil Karras
02-24-2003, 02:40 PM
Try this:

function Send_Form(form){
for (i=1; i< document.getElementById('Tabla_Estudios').rows.length;i++){
for (j=1;j<=6;j++){
var objInput1 = document.createElement("INPUT");
objInput1.type = "HIDDEN";
objInput1.name = "Careers"+i+j;
objInput1.value = document.getElementById('celda'+i+j).valor;

// -------------------------------------------------
// Try this to see if you really are getting
// the value you think you're getting
// -------------------------------------------------
alert(document.getElementById('celda'+i+j).valor);
// -------------------------------------------------

form.appendChild(objInput1);
}
}
form.submit();
}

My guess is that this will tell you that you are not really returning the value you think you are, but this should prove it one way or the other.

Caliban
02-24-2003, 02:54 PM
Hi Phil!
That's what I did in first instance.

With the alert, I noticed "document.getElementById('celda'+i+j).valor" was truncated.

I know in the TEXT inputs, if you don't enclose the TEXT value between ' ' , it only takes characters until the first space.


But, how can I enclose
document.getElementById('celda'+i+j).valor
between ' ' ??? :confused:


Cheers
Caliban

Phil Karras
02-24-2003, 03:03 PM
You'll have to show me what you did for valor on this element:
document.getElementById('celda'+i+j).valor
I have no idea what a "valor" is.
[code]document.getElementById('Name'); is an object, and I'm assuming valor is a property, but I think you'd better give that part of the code so I can see & perhaps play with it.

Caliban
02-24-2003, 03:11 PM
OK Phil,

"valor" is an attribute of the cell.

______________________________________________
document.getElementById('celda'+i+j).valor
______________________________________________
when j = 5 (column 5 of the table), there is a TEXT input in the cell.

You could replace it by
______________________________________________
document.getElementById('celda'+i+j).MyVal
______________________________________________

and it's the same, coz "MyVal" it's an attribute of the cell.

I'm very busy at this moment, but if you have me some patience, I will give you the code later.

Cheers,
Caliban

Phil Karras
02-24-2003, 03:25 PM
I don't want all your code, just a small page with one element and the function that gets the value.

I don't need the whole page nor do I have time to hunt through it to help you. (I get paid for doing that kind of thing.) So make it a KISS (Keep It Short & Simple) example and I'll help.