CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

  Return value from hidden field to use in RemoteCustomCode

Print topic Send  topic

Author Message
gerrit


Posts: 131
Posted: 09/11/2015, 4:21 AM

hi,

I have a grid whit user details and a button(Edit User ) whit loading bar.
now I want that the button get the value from the user_id so I can edit the user

I have use this scrip

$('#actionButton').one('click',function(e){
e.preventDefault();

var button = $(this)
button.progressTimed(2, function(){
//button.click(function(){
$(window.document.location).attr('href', 'adm_users.php?user_id={ ??? }');
//href('index.php');
//});
});
});

Thanks,
_________________
| http://www.vision.to |
View profile  Send private message
saseow

Posts: 727
Posted: 09/11/2015, 7:37 AM

Make the button a link (use CCS to make it look like a button if you want), link to the page where your edit form is (most probably the same page as the grid) and add a parameter - Datafield and select the ID of the record and a name and away you go. Edit forms default to 'ID' so may as well name the parameter name 'ID'.
View profile  Send private message
gerrit


Posts: 131
Posted: 09/11/2015, 8:02 AM

hi,

I know, but I want a button whit Loadingbar
I try to use this http://tutorialzine.com/2013/10/buttons-built-in-progress-meters/
And I use bootstrap.


_________________
| http://www.vision.to |
View profile  Send private message
saseow

Posts: 727
Posted: 09/11/2015, 8:14 AM

Aaah, OK, you are on your own here I am afraid. Sorry.
Nice button though!
View profile  Send private message
MichaelMcDonald

Posts: 638
Posted: 09/12/2015, 4:31 PM

I've never seen any other way to make a link work other than as a link with a PHP select grid.

I have seen a jquery tutorial where you can read the id value from a link in a jquery grid.

In PHP what I do these days is obscure the ID by encrypting the link in it's before show event using a key
that is randomly generated once off, everytime a userlogin occurs, and stored as a session variable, like this:

Set the $key at login:

index_events.php....

//Login @6-BAF3F8A0
global $CCSLocales;
global $Redirect;
if ( !CCLoginUser( $Container->login1->Value, $Container->password->Value)) {
$Container->Errors->addError($CCSLocales->GetText("CCS_LoginError"));
$Container->password->SetValue("");
$Login_Button_DoLogin_OnClick = 0;
} else {
$key = substr(str_shuffle(str_repeat('ABCDEFGHJKMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz23456789!@#%^&*_-+',5)),0,16);
CCSetSession("key",$key);
global $Redirect;
$Redirect = "/BVS/dt.php";
}
//End Login

//Close Login_Button_DoLogin_OnClick @3-0EB5DCFE
return $Login_Button_DoLogin_OnClick;
}
//End Close Login_Button_DoLogin_OnClick

//Login_OnValidate @2-6A7D1BF2
function Login_OnValidate(& $sender)
{
$Login_OnValidate = true;
$Component = & $sender;
$Container = & CCGetParentContainer($sender);
global $Login; //Compatibility
//End Login_OnValidate


in a live processing page...

in before show of a link , take the id from a hidden field in the link row $url = $dt1->iddt->GetValue(); , encrypt and inject it into the link...

$dt1Page = CCGetFromGet("dt1Page");
$key = CCGetSession("key");
$url = $dt1->iddt->GetValue();
$encrypted = CCEncryptString($url, $key);

$dt1->Link1->SetLink("dt.php?iddt=" . $encrypted . "&dt1Page=" . $dt1Page);


then in the page before initialize event:

$key = CCGetSession("key");

$iddt = CCGetFromGet("iddt");
if($iddt != NULL){
$iddt = CCDecryptString($iddt, $key);

CCSetSession("iddt", $iddt);
}


and in your grid select it's WHERE id = id, session

and this always displays the id differently after every login, every time, for every user in it's encrypted form in the url bar, so it's not easy for anyone to detect the db id from the value in the url bar.

_________________
Central Coast, NSW, Australia.

View profile  Send private message
MichaelMcDonald

Posts: 638
Posted: 09/13/2015, 4:03 AM

Have a look at this post:

How to access the control values of editable grids, it might provide a clue for retrieving the ID from a RowValue in a PHP driven grid.

http://forums.yessoftware.com/posts.php?post_id=60507


And then imagine you would set the link class to "Button" so it inherits the attributes you require and can be made to display progress.


I might play around with the JS that post myself see if I can make a jquery script, bit of a personal challenge.

Anyway if this sounds like what you are looking for can you start posting here and I can get involved.
_________________
Central Coast, NSW, Australia.

View profile  Send private message
gerrit


Posts: 131
Posted: 09/13/2015, 11:59 AM


Hi,

Thanks for response micheal, I Will take a look to your url its looks great.
Now I am verry ill, If it go better whit me I look to it



Quote MichaelMcDonald:
Have a look at this post:

How to access the control values of editable grids, it might provide a clue for retrieving the ID from a RowValue in a PHP driven grid.

http://forums.yessoftware.com/posts.php?post_id=60507


And then imagine you would set the link class to "Button" so it inherits the attributes you require and can be made to display progress.


I might play around with the JS that post myself see if I can make a jquery script, bit of a personal challenge.

Anyway if this sounds like what you are looking for can you start posting here and I can get involved.

_________________
| http://www.vision.to |
View profile  Send private message
MichaelMcDonald

Posts: 638
Posted: 09/13/2015, 4:23 PM

I am VERY excited, found this and it works. No more ID n the url bar !!!! edit every record as a session variable....

Here's the link....

http://stackoverflow.com/questions/19957321/get-td-valu...ith-mouse-hover

I changed mouse hover to click and it works....

<script>
$(document).ready(function(){
$('tr').click(function(){
var valueOfTd = $(this).find('td:first-child').text();
alert(valueOfTd); // Do here what you want with the value.
});
});
</script>

You just click on the table row you want, and it grabs the label value from the first TD. In this example, that value will be displayed and proven in an alert window.If this is a DB ID you now use this in an ajax post query to set a PHP session variable,

I will write how i think it should works, but I have no open projects to test with so if someone could test my code I would be grateful. It will be very close. You could then post in Tips & Solutions with credit to us all.

The untested jquery... I usually mess up the number of these things "});" until i get a chance to test so call me on how many there are....

Anyway, try this....

<script>
$(document).ready(function(){
$('tr').click(function(){
var iduser = $(this).find('td:first-child').text();
data = "iduser=" + iduser;

$.ajax({
url: "setidusersession.php",
type: "POST",
data: data,

success: function(){
$('#formmessage).val("Working"); // need this for it to work so make hidden field if necessary
},
error: function(errormessage) {
$('#formmessage').val("Not Working."); // need this for it to work so make hidden field if necessary
}
});
}
}
});
});
</script>


then setidusersession.php before show event (in fact you might even be able to put this in the before initialize event of the same page as the one you are POSTING from....

$iduser = CCGetFromPost("iduser");
CCSetSession("iduser",$iduser);

and if you want you can now switch your user record visible or not by putting it in a panel and

before show:

$record->visible = false;
if(CCGetSession("iduser") > 0){
$record->visible = true;
}

and when you are finished updating in the after update or update button click put:

CCSetSession("iduser",""):

or you hide/show the div containing the user record depending on a variable, see the above post. You could setup hide/show/change value/update record without so much as screen reload if you did your validation jquery aswell.

might as well drop some jquery validation example here :) : while I;m on a roll...

<script>
$().ready(function() {
$( "#contactformButton_Insert" ).click(function() {
var emailok = 0;
var name = $('#contactformname').val();
var email = $('#contactformemail').val();
var subject = $('#contactformsubject').val();
var message = $('#contactformmessage').val();

if(message == ''){
$('#contactformerror').val("Message is required.");
}



var atpos = email.indexOf("@");
var dotpos = email.lastIndexOf(".");
if (atpos< 1 || dotpos<atpos+2 || dotpos+2>=email.length) {
$('#contactformerror').val("Email is not valid.");
var emailnotok = 1;
}



if(email == ''){
$('#contactformerror').val("Email is required.");
}

if(name == ''){
$('#contactformerror').val("Name is required.");
}

if(subject == ''){
$('#contactformerror').val("Subject is required.");
}

var key = 'f@C[Y(QK2Ee';

var data = "name=" + name + "&email=" + email + "&subject=" + subject + "&message=" + message + "&key=" + key;

if((name != '') && (email !='') && (emailnotok != 1) && (subject != '') && (message !='')){

$.ajax({
type: "POST",
url: "inc/sendmail.php",
data: data,
success: function(phpReturnResult){
$('#contactformerror').val("Thank You For Your Email.");
},
error: function(errormessage) {
$('#contactformerror').val("Thank You For Your Email.");
}
});


}
});
});
</script>





GERRIT, I suspect this is part 1 of a 3 part solution. An ID can now be used in a PHP grid to call anything, and then there would be another script as part of the .css library that progressively gradient fills the link which has been give a class" button", and to achieve that we will have to determine how to write back to the appropriate rowlink (TD) again containing that link which initiated the download with the class "button: using jquery and I will do some investigation into this.

And you could probably run multiple concurrent downloads.

All hail JQuery !
_________________
Central Coast, NSW, Australia.

View profile  Send private message
gerrit


Posts: 131
Posted: 09/21/2015, 12:04 PM

hi,

thanks MichaelMcDonald I will test it if I have time, I will try something else, I would first like to start doing something with toastr

http://forums.yessoftware.com/posts.php?post_id=124691
_________________
| http://www.vision.to |
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright 2003-2004 by UltraApps.com  and YesSoftware, Inc.