hi, i'm working with a drupal 6 installation, where the user after the registration, the user has to insert some of his data (like email, earnings, and other economic stuff).

the problem is, that when you try to click on "save" nothing happens, and if i refresh the page, none of the data i put is there.

how can i solve this????

Comments

stokks’s picture

hi, i figured out how to save data, by changing a js function that was called, and inserting that in the "save" button in php.

but now the problem is that it only saves data when i click on it TWO times! how can i solve this problem?

it's driving me nuts! ;)

heine’s picture

You might want to elaborate on the background of the problem. Eg, explain what scripts / modules you are using.

stokks’s picture

do you mean generally or in the module?

i'm using the zen theme, drupal 6.17, php 3.52, mysql 5.1.48.

the php script on the drupal page is

<div class="generic botonGuardar">
	<input type="button" value="Guardar" onclick="guardaTodo()"/>
</div>

(guardar is save in spanish), while the js function is

function guardaTodo(){
	guardarMisDatos();
	guardarAtributos();
}

which calls to functions, that are

function guardarMisDatos(){
		
... all the variables saved... and at the end	 

	var param = "usuario=" + usuario + "&nivel=" + nivel + gano + porc_gano + gasto + porc_gasto + tengo + porc_tengo + debo + porc_debo + plazo_debo;
	
	var s = document.createElement("script");
	h = document.getElementsByTagName("head")[0];
	s.src = direccion_servidor + "setMisDatos?callback=respuestaGuardarMisDatos&param=" + encodeURIComponent(param);
	h.appendChild(s);
	
	//var direccion_completa = direccion_php + "setMisDatos.php?param=" + encodeURIComponent(param);
	//xmlhttp.request(direccion_completa, respuestaGuardarMisDatos);
}

while the other function works perfectly. i even have to say that it works better on chrome and firefox than in explorer 8.

if i try to do the callback of the function i get 90% of the times the correct savings.

stokks’s picture

nobody can help me with this? i have been trying all the day today trying to figure it out, but nothing! pleeease ;)

john_b’s picture

Sorry I cannot fix your php. The thread looks rather unusual.

You say

php 3.52,

, that has to be a mistake?

As for php on the Drupal page, do you really have so much php on the page? Or is it in a module? It is not normal to make a Drupal page with so much php, and sometimes it does not work as expected.

Digit Professionals specialising in Drupal, WordPress & CiviCRM support for publishers in non-profit and related sectors

stokks’s picture

oh yes it's 5.32 php, and actually the two functions are in the javascript file is inside the theme folder. but it's true that there is a lot of code on one drupal page (a content page).... do you know a way i can fix that?

john_b’s picture

Not really. It depends what the page has to do! The alternative to putting a lot of js in the theme is to put it into a module.
http://drupal.org/node/304255

Digit Professionals specialising in Drupal, WordPress & CiviCRM support for publishers in non-profit and related sectors

stokks’s picture

the page has to save datas from the user (economical data), there are four minitabs with "what i earn", "what i have", "my debts", etc... and at the end of every minitab there is such a button to save, the one that gives me this problem... so i don't think i should put it in a module right?

john_b’s picture

Probably not.

You might look here http://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_a...

I did not see the guardarAtributos(); defined in your code.

Sometimes js errors are solved by disabling 'aggregate javascript' under Performance in configuration.

Digit Professionals specialising in Drupal, WordPress & CiviCRM support for publishers in non-profit and related sectors

stokks’s picture

i just verified that aggregate javascript was already disabled. the page where i have the problem is a content with a php script of 1980 lines, but i don't think it would be better to change the structure of it, since it would take a lot of time...

about the link you sent me, i don't see which part should help me, the only thing that i understood is that my javascript file works as inline...

i didn't post the function guardaAtributos() because i think it works perfectly (since it saves only the data of the first minitab, and it works). Anyway here is the important part:

function guardarAtributos(){

.... all the variables... 

var usuario =  miGetElementsByClassName('title', document.getElementById('block-user-1'))[0].innerHTML;
	var s = document.createElement("script");
		
	s.src = direccion_servidor + "setMisAtributos?usuario="+ usuario + "&callback=cargarAtributosUser&dni=" + dni + "&email=" + email + "&hijos=" + hijos + "&personas_cargo=" + personas_cargo
			+ "&sexo=" + sexo + "&situacion_laboral=" + situacion_laboral + "&entidad_representada=" + entidad_representada + "&estado_civil=" 
			+ estado_civil + "&modalidad_ingresos=" + modalidad_ingresos + "&independiente=" + independiente + "&fecha_nacimiento=" + fecha_nacimiento + "&fecha_nacimiento=" + fecha_nacimiento + "&nivel_anual_ingresos=" + nivel_anual_ingresos + "&prof_lib=" + prof_lib 
			+ "&gestion_caida_valoracion=" + gestion_caida_valoracion + "&nivel_experiencia_inversora=" + nivel_experiencia_inversora
			+ "&entidad_deudas=" + entidad_deudas + "&nivel_conocimiento_empresas=" + nivel_conocimiento_empresas+ "&nivel_conocimiento_comisiones=" + nivel_conocimiento_comisiones + "&horizonte_inversion=" + horizonte_inversion 
			+ "&nivel_autogestion=" + nivel_autogestion + "&analisis_tecnico=" + analisis_tecnico + "&usuario_activo=" + usuario_activo 
			+ "&nivel_acceso_inf_financiera=" + nivel_acceso_inf_financiera + "&acciones_preferentes=" + acciones_preferentes + "&fondos_materias_primas=" + fondos_materias_primas 
			+ "&usa_cds=" + usa_cds + "&usa_etfs=" + usa_etfs + "&contratos_diferencias=" + contratos_diferencias + "&dinero_invertir_activos=" + dinero_invertir_activos 
			+ "&productos_estructurados=" + productos_estructurados + "&derivados_financieros=" + derivados_financieros
			+ "&rotacion_activos=" + rotacion_activos + "&ent_prox_fisica=" + ent_prox_fisica + "&ent_prox_mental=" + ent_prox_mental + "&canal_preferente=" + canal_preferente ;
		var h = document.getElementsByTagName("head")[0];
		h.appendChild(s);
}

it's really driving me nuts ;) if there could be a quick way to fix it i would be grateful forever!

stokks’s picture

i'm still stuck with this problem, can't find a solution... can anybody help me?

stokks’s picture

i've found out that using the firefox web console, that the function calls undefined the first time 1 click on it, and HTTP/1.1 200 OK the second time i click on the save button...

is it a problem with the appendchild call?