Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
getCol and pb with array return
11/06/2010
17:49
Avatar
missa
france
Member
Members
Forum Posts: 104
Member Since:
20/02/2009
sp_UserOfflineSmall Offline

Hello,

I have a pb to extrat information from array wich is returns by the method: getCol.

This is my cod in my javascript page.

var $tb = $("#liste_produit").getCol('eta_actif',true); $.ajax({ type: "POST", url: $url_aj, data: "typ_requete=enr_grid&tb="+ $tb, success: function(contenu){ alert(contenu); }, error: function(objet,type){ alert('error: ' + type); } });

the result is like this: [{id:1,value:val1},{id:2,value:val2},{id:3,value:val3},{id:...,value:..}]

How  can I get back various values of the various array.

Thank you for your help.

Regards

MissaKiss

11/06/2010
17:51
Avatar
missa
france
Member
Members
Forum Posts: 104
Member Since:
20/02/2009
sp_UserOfflineSmall Offline

I forget I thing, I want use values in php pages and not in my javascipt page.

11/06/2010
17:58
Avatar
Asshiah
Member
Members
Forum Posts: 74
Member Since:
27/04/2010
sp_UserOfflineSmall Offline

If you wanted to use it in the javascript code It would probably be something like this:

var contenu2 = JSON.parse(contenu);
alert(contenu2[1]);
11/06/2010
18:11
Avatar
Asshiah
Member
Members
Forum Posts: 74
Member Since:
27/04/2010
sp_UserOfflineSmall Offline

In fact, you response is not a valid JSON string so I think it won't work as i told you...

maybe like this but I am not sure it will work with your type of string:

var contenu2=JSON.parse(contenu);

alert(contenu2[1].value);

14/06/2010
10:46
Avatar
missa
france
Member
Members
Forum Posts: 104
Member Since:
20/02/2009
sp_UserOfflineSmall Offline

Thank you Asshiah,

but it doesn't work. I want use this data in PHP page and not in javascript.

Nothing work it's very despairing.

Regards.

Missa

15/06/2010
11:39
Avatar
missa
france
Member
Members
Forum Posts: 104
Member Since:
20/02/2009
sp_UserOfflineSmall Offline

Hello,

I find! It is my AJAX request! It doesn't like object.That why I do this:

/* fonctionnalité du bouton envoyer de la page ajout et consultation*/ var $donnees_get = ""; var $liste_ajax = ""; $donnees_get = $("#liste_produit").getCol('eta_actif',true); for ($valeur in $donnees_get){ $liste_ajax = $liste_ajax + '|("' + $donnees_get[$valeur].id.substring(0,5) + '","' + $donnees_get[$valeur].id.substring(6,9) + '","' + $donnees_get[$valeur].value + '")' ; } $liste_ajax = $liste_ajax.substring(1); $.ajax({ type: "POST", url: $url_aj, data: "typ_requete=enr_grid&liste_ajax="+ $liste_ajax, success: function(contenu){ /*alert(contenu);*/ }, error: function(objet,type){ alert('error: ' + type); } });

And after that, Everything work in my Php page. I do this: 

if ($_REQUEST['typ_requete'] == 'enr_grid') { $donnees = explode("|",$_REQUEST['liste_ajax']); foreach ($donnees as $valeur){ $id = explode(',',$valeur); $SQL = "UPDATE rf.ft_produit_codif SET eta_actif = ".substr($id[2],0,3)." WHERE cod_produit = ".substr($id[0],1,7)." AND cod_origine = ".substr($id[1],0,5); $result = mysqli_query($link,$SQL); } }

RegardsKiss

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
59 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information