hello, how to get member username with js? if you use the automatic value built in appgini whenever you call $j.val() it returns "" and I need it to return the username value, any ideas?
Thank you.
how to get member username with js?
- D Oliveira
- AppGini Super Hero
- Posts: 348
- Joined: 2018-03-04 09:30
- Location: David
Re: how to get member username with js?
If you use a field with that automatic value it should become a static control div and not an input. This means you cannot use .val() method. Try .text() instead:
var user = $j("created_by").text();
Regards,
Jan
var user = $j("created_by").text();
Regards,
Jan
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
- D Oliveira
- AppGini Super Hero
- Posts: 348
- Joined: 2018-03-04 09:30
- Location: David
Re: how to get member username with js?
you sir are a genius, well deserved title/badge. one more question, how do you verify that the user name matches the text extracted from that field?
That reference should be accessible to all appgini users like the select2 tweaks and .reload features. thank you!
- D Oliveira
- AppGini Super Hero
- Posts: 348
- Joined: 2018-03-04 09:30
- Location: David
Re: how to get member username with js?
user udayvatturi posted somewhere the solution, here it is:
Code: Select all
Ajax Call
var url1="getMemberInfo.php";
jQuery.ajax({
url: url1,
dataType: 'json',
success:function(response){
//alert(response); //display memberinfo['username']
if( $j('#createdby').text() == response ){
console.log('here')
}
}
});
getMemberInfo.php
<?php
$curr_dir = dirname(__FILE__);
include("{$curr_dir}/defaultLang.php");
include("{$curr_dir}/language.php");
include("{$curr_dir}/lib.php");
$mi = getMemberInfo();
echo json_encode($mi['username']);
?>
- D Oliveira
- AppGini Super Hero
- Posts: 348
- Joined: 2018-03-04 09:30
- Location: David
Re: how to get member username with js?
also you wanna add that to your tablename-dv.js if you're trying to accomplish the same:D Oliveira wrote: ↑2019-05-31 23:01user udayvatturi posted somewhere the solution, here it is:
Code: Select all
Ajax Call var url1="getMemberInfo.php"; jQuery.ajax({ url: url1, dataType: 'json', success:function(response){ //alert(response); //display memberinfo['username'] if( $j('#createdby').text() == response ){ console.log('here') } } }); getMemberInfo.php <?php $curr_dir = dirname(__FILE__); include("{$curr_dir}/defaultLang.php"); include("{$curr_dir}/language.php"); include("{$curr_dir}/lib.php"); $mi = getMemberInfo(); echo json_encode($mi['username']); ?>
Code: Select all
jQuery('#update').hide();
//or
jQuery('#update').show();
Re: how to get member username with js?
hello
i have other way dont know if can be fine or not
this code to show current login Group , and can change to to show current user
i add this code infooter-extras.php
and add this code on table-dv.js to make sure its working
i have other way dont know if can be fine or not
this code to show current login Group , and can change to to show current user
i add this code infooter-extras.php
Code: Select all
<?php
$mi = getMemberInfo();
?>
<script>
var AdminUser = "<?php echo $mi['group']; ?>" ;
//alert(AdminUser);
</script>
Code: Select all
alert(AdminUser);