CodeCharge Studio
search Register Login  

Visual Web Reporting

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

YesSoftware Forums -> CodeCharge Studio -> PHP

 Auto Populate Textboxes using var - (RESOLVED)

Print topic Send  topic

Author Message
SecureCloud


Posts: 51
Posted: 12/02/2012, 9:05 PM

i have a record, with all textboxes, after they fill in Textbox1, i want to have a button to 'Calculate', right after it. then take my vars and populate the textboxes. (i hope i explained that right...)

First...
i will need the value of the textbox1 - ($var1 is used to get external url vars)
ex.
 $html = file_get_html('http://www.someurl.com/sub/' . $var1);  

so after they fill in textbox1 whatever that value is, whatever was typed in (not yet stored in db), i need to store it in $var1, then the button to 'Calculate', ( this DOESNT work.. but its close.. )
 $var1 = $Component->Textbox1->GetValue(); 


after that runs all my other vars get populated... then i need to auto-populate the rest of the textboxes... ( NOT sure if this works... )
$Component->SetValue($Container->Textbox2->SetValue($aa));   
$Component->SetValue($Container->Textbox3->SetValue($bb));   
$Component->SetValue($Container->Textbox4->SetValue($cc));  

$aa, $bb, $cc are my vars that get populated after the $html gets run,... then i want to auto-populate the rest of the textboxes... if it seems confusing i'm sorry.. PLEASE HELP...

p.s., yes i am using simpleHtmlDom, my form works as a seperate php page, i wanna incorporate it into CCS5.

also it worked on my other page because i was using .. $var1 = $_GET['var1']; ... that was taking it from url, now i need to take it from whatever gets entered in textbox1, on change, or lost focus, or 'Calculate' button.
_________________
-------------------------------------------------------------------------------------------------
If this helped You, Please Donate to SecureCloud Here, ANY amount Accepted.
http://securecloud.biz/donate/
Thank You, Your help Keeps us Going.

View profile  Send private message
Lucius

Posts: 220
Posted: 12/03/2012, 1:20 AM

Something is unclear for me here.

You show the code for PHP server-side setting and getting values, but later on you reffer to client-side events (like on lost focus or on change).

Are you trying to do this server-side or client-side? Or is this some mix of ajax calls to server-side services?
View profile  Send private message
SecureCloud


Posts: 51
Posted: 12/03/2012, 9:34 AM

i made this page as a separate php script with GET var1 thru url.
now i am trying to incorporate this into CCS5, so to be honest, i dont know the best way to do this, the sample code i've shown is to show u what i wanna do (kinda)...

if someone could show me the best route to take.

i guess the on change would occur when they fill in the textbox1,

the main script i wrote was server-side...

i am new to CCS5, i would like to see how is the best way.

like i said i have a php script that this already works on, using _GET $var1 thru url.... then i can echo all the vars

my problem is HOW to bring this into CCS5.... should i leave it as a separate page and pass textbox1 to url parameter ?
then populate the rest of the textboxes ??


_________________
-------------------------------------------------------------------------------------------------
If this helped You, Please Donate to SecureCloud Here, ANY amount Accepted.
http://securecloud.biz/donate/
Thank You, Your help Keeps us Going.

View profile  Send private message
bannedone


Posts: 273
Posted: 12/03/2012, 7:24 PM

tj

This is very confusing.

What is suppose to happen?

Someone puts a value in the first text box then hits calculate??

What is calculated??

What goes in the rest of the text boxes??

Need a little more info.




_________________
John Real
CodeCharge Studio Support, Training, Consulting, Development, Web based solutions
http://realsites.biz
http://ccselite.com
Other Banned IDs on this Forum. jjrjr1, jjrjr2
View profile  Send private message
SecureCloud


Posts: 51
Posted: 12/03/2012, 8:31 PM

yes, they put a value in textbox1, then hit 'calculate'...
this will run a function using simpleHtmlDom on an external url (code above)

i want to take those results and populate textbox2, textbox3, textbox4 and so on.

i know this is a pain in the butt... i'm sorry
_________________
-------------------------------------------------------------------------------------------------
If this helped You, Please Donate to SecureCloud Here, ANY amount Accepted.
http://securecloud.biz/donate/
Thank You, Your help Keeps us Going.

View profile  Send private message
bannedone


Posts: 273
Posted: 12/03/2012, 8:46 PM

What exactly happenes when they hit calulate??

Does it submit the form???

What is simpleHtmlDom?? You 8need to remember that CCS is a MVC Framework..

An external url?? Are you running the calculate function via AJAX??

A little more detail as to the required functionality would help

What is the function suppose to do???

_________________
John Real
CodeCharge Studio Support, Training, Consulting, Development, Web based solutions
http://realsites.biz
http://ccselite.com
Other Banned IDs on this Forum. jjrjr1, jjrjr2
View profile  Send private message
SecureCloud


Posts: 51
Posted: 12/03/2012, 9:05 PM

ok, sorry to be so cryptic, just hard to explain... so here it is step by step

this is the code i have that works as a separate php page, i want to incorporate it into CCS5
  
include_once('simple_html_dom.php');    
    
$var1 = $_GET['var1'];  //this was used  gettin  thru URL    
$html = file_get_html('http://www.someurl.com/vin/' . $var1);    
    
$aa = $html->find('tr', 7)->find('td', 6);    
$bb = $html->find('tr', 7)->find('td', 10);    
$cc = $html->find('tr', 7)->find('td', 14);    
$dd = $html->find('tr', 7)->find('td', 26);    
$ee = $html->find('tr', 7)->find('td', 48);    
    
    
$html->clear();    

this code, works thru url parameter ....com/?var1=123456567
it returns 5 parameters i have stored into vars, $aa, $bb, $cc...etc...
i can echo them out.. that works. at this point they r stored in the vars.

NOW...
i'm not sure how to do this, so bare with me...
i want to create a record, so when the user comes to page, he/she will enter in VAR number, then hit 'calculate' , the code above will run using using the VAR THEY ENTERED IN THAT TEXTBOX
at this point its NOT stored anywhere yet, but that value needs to replace the _GET(var1)....
(not sure how to replace the _GET(var1) yet.)... it will take textbox1, run code above, return list of vars populated, THEN populate the rest of the textboxes using the info from the vars....

thats step by step...

PLEASE HELP

should i just use my code page as an INCLUDE ?
i dont know where to place anything, then call it... lol
_________________
-------------------------------------------------------------------------------------------------
If this helped You, Please Donate to SecureCloud Here, ANY amount Accepted.
http://securecloud.biz/donate/
Thank You, Your help Keeps us Going.

View profile  Send private message
Lucius

Posts: 220
Posted: 12/03/2012, 11:13 PM

Alright now it is clear for me :)

First thing is that you are working here with server-side events, so you will need to use the "Calculate" button.

If you would like to use events client-side like onFocus, onKeyUp, etc... you would need to modify your code to use some AJAX service for fetching data.

So let's focus on the server-side for now, let's make it working.

First of all I don't see a problem in using the previous code in CCS (the "include_once('simple_html_dom.php'); " line) and the parsing of values you received, but you need to test it if it actually works.

Uncomment the "echo" lines from previous version of your script and add "die();" after them. This will make the script exit at this point and you will see if the values are really there:

  
include_once('simple_html_dom.php');    
    
// $vin1 = $_GET['vin1'];  //this was used  gettin  thru URL    
$vin1 = $Component->car_vin->GetValue();  // now trying to getValue from textbox instead or URL    
  
echo('VIN from component: '.$vin1.'<br>');  
    
$html = file_get_html('http://www.someurl.com/vin/' . $vin1);    
    
$aa = $html->find('tr', 7)->find('td', 6);    
$bb = $html->find('tr', 7)->find('td', 10);    
$cc = $html->find('tr', 7)->find('td', 14);    
$dd = $html->find('tr', 7)->find('td', 26);    
$ee = $html->find('tr', 7)->find('td', 48);    
    
// these echo's work on php script    
echo($vin1 . '<font color="#FF0000">   This is VIN <br></font>');    
echo($aa . '<font color="#FF0000">   This is YEAR <br></font>');    
echo($bb . '<font color="#FF0000">   This is MAKE <br></font>');    
echo($cc . '<font color="#FF0000">   This is MODEL <br></font>');    
echo($dd . '<font color="#FF0000">   This is BODY-STYLE <br></font>');    
echo($ee . '<font color="#FF0000">   This is WEIGHT <br></font>');    
  
die();  

Please let us know what was the output here after you pressed the calculate button.

Also a side question - where do you attach the above code exactly in CCS page? On which object and which event of this object?
View profile  Send private message
DataDoIT
Posted: 12/04/2012, 4:47 AM

This is precisely where AJAX shines.

The Calculate button will invoke the AJAX call with the values to
calculate and await the response. The server-side PHP script will do
the calculations (recognize that could also be an external script or web
service that is called via cURL) and compile the results into the
appropriate XML format. When the response is received (the XML built)
the text boxes can then be populated with the calculated values.

That's the solution in a nutshell. Recognize this isn't done using
CCS's built-in AJAX garbage. For a working sample then you're going to
have to go on the clock.
SecureCloud


Posts: 51
Posted: 12/04/2012, 10:10 AM

to Lucius...

i am tryin the code now.. thx...(i'm stuck at this part, and cant move on til i get it...)

to answer ur side question, thats the thing i havent attached it nowhere yet, not even sure WHERE to attach it, i just have the code that works, and i need to incorporate it into CCS,

i'm new to CCS programming, experienced in php tho, i need to get the hang of referencing objects, i have read just about everything in the last 3 weeks... sooo many practice projects...

any ideas how to attach this event ??

also, DataDoIT, .. i would think ajax would be the way to go on this, any code samples i can look at ??


also Lucius, tried it, i get this error...

Fatal error: Call to a member function GetValue() on a non-object in /home/.../test1/cars_edit_events.php on line 24

LINE 24:
$var1 = $Component->Textbox->GetValue(); // now trying to getValue from textbox instead or URL


i created record then, created a FORM button then, event->server->onClick->CustomCode-> then attached ur code sample... and error.

In my script, that info is stored each in a separate var, and echo'd out.

to recreate, you could use that page as an include, then create a RECORD with those fields, create a 'calculate' button that refreshes the page, and auto-fills the rest of the textboxes, similar to my image i posted above ...

could i use that as a service for ajax ? would that be easier to refresh the textboxes ??? How would i go about that way ???


_________________
-------------------------------------------------------------------------------------------------
If this helped You, Please Donate to SecureCloud Here, ANY amount Accepted.
http://securecloud.biz/donate/
Thank You, Your help Keeps us Going.

View profile  Send private message
Lucius

Posts: 220
Posted: 12/04/2012, 1:52 PM

Ok, so try this now then:

Create a CCS page (if you haven't done this already) with the form you have on the screen.

Click on the "Calculate" button and create a server side event OnClick (Properties panel after you click the button). In this event place the code I have quoted.

Make sure that the objects are properly referenced - you need to properly reference the textbox where you input the VIN, so this code:

$vin = $Component->car_vin->GetValue();

Will become something like this:
$vin = $YOUR_FORM_NAME->YOUR_VIN_TEXTBOX_NAME->GetValue();

And then compile and run page, click the button.


PS. The AJAX is the way to do this, and you can use json, sure. However first you need to get some basics in CCS, otherwise it will be too much stuff at once. When you get the hang of basics, it will be very easy to implement ajax call :-)
View profile  Send private message
SecureCloud


Posts: 51
Posted: 12/04/2012, 2:02 PM

i replaced
 $var1 = $Component->Textbox->GetValue(); 

with
 $var1 = $NewRecord1->Textbox->GetValue(); 

and i see the page i made, with ur echo on there...
now imma try to tie that to textboxes...

  
// trying to pass vars to textbox    
$NewRecord1->Textbox->SetValue($aa);    
$NewRecord1->Textbox->SetValue($bb);    
$NewRecord1->Textbox->SetValue($cc);    
$NewRecord1->Textbox->SetValue($dd);    
$NewRecord1->Textbox->SetValue($ee);   

NOPE.. that code above gives me a blank page..... :-(

after i click it looks like this
vars_edit.php?ccsForm=NewRecord1


_________________
-------------------------------------------------------------------------------------------------
If this helped You, Please Donate to SecureCloud Here, ANY amount Accepted.
http://securecloud.biz/donate/
Thank You, Your help Keeps us Going.

View profile  Send private message
Lucius

Posts: 220
Posted: 12/04/2012, 2:21 PM

If you have included the "echo" lines I quoted previously, you need to receive some output, even if the code fetching the VIN would fail...

The result should be some text and a blank page (the "die();" function exits the php processing - it is useful for debugging code)
View profile  Send private message
SecureCloud


Posts: 51
Posted: 12/04/2012, 2:35 PM

i keep testing, the code u provided, shows me the original page with all my vars and info, like its suppose to, now the problem is tying them to textboxes...
i kept all the code except the echo's, now what ??

which is the correct syntax...
$NewRecord1->$DBConnection1->Textbox->SetValue($aa);

or
$NewRecord1->Textbox->SetValue($aa); 

how do i tie my vars to textboxes ??

**NOTE: after removing the echo's i get a blank page, its like the record grid is gone, how do i re-show it ??

_________________
-------------------------------------------------------------------------------------------------
If this helped You, Please Donate to SecureCloud Here, ANY amount Accepted.
http://securecloud.biz/donate/
Thank You, Your help Keeps us Going.

View profile  Send private message
SecureCloud


Posts: 51
Posted: 12/04/2012, 6:08 PM

I'm sorry to bother everyone, but this step is taking too long, its been 3 days and i'm nowhere.

i have JSON results

how can i take those results and make a service that autofills my textboxes ???

Lucius, when i use ur code i lose my whole page, i cant reference something that isnt there anymore, can SOMEONE PLEASE HELP ME.... ANYONE..??? :-(


_________________
-------------------------------------------------------------------------------------------------
If this helped You, Please Donate to SecureCloud Here, ANY amount Accepted.
http://securecloud.biz/donate/
Thank You, Your help Keeps us Going.

View profile  Send private message
bannedone


Posts: 273
Posted: 12/04/2012, 10:49 PM

Hi

Looks like you have all the elements you need to make this work

Your JSON page could be used as your AJAX service

http://sms.securecloud.biz/vin-decode1.php?vin1=1D7HU18Z52J227056

But you need to fix it and stop it from sending any HTML
(maybe rebuild it using the CCS Service Builder)

On your form Change the Calculate button from a Submit button and make it just a button.

Put an onclick="your_ajax_function(this)" in the HTML for that button.

In this function just get the value of the VIN from the Value passed to the function.
Make your AJAX call with the URL to your service sending the VIN in the URL.

When your service returns the JSON data parse it and put it into the respective fields in your form.

Have Fun
8-)

BTW.. This is all done Client Side in Javascript calling your PHP AJAX service..

_________________
John Real
CodeCharge Studio Support, Training, Consulting, Development, Web based solutions
http://realsites.biz
http://ccselite.com
Other Banned IDs on this Forum. jjrjr1, jjrjr2
View profile  Send private message
Lucius

Posts: 220
Posted: 12/05/2012, 12:31 AM

Quote SecureCloud:
I'm sorry to bother everyone, but this step is taking too long, its been 3 days and i'm nowhere.

i have JSON results
http://sms.securecloud.biz/vin-decode1.php?vin1=1D7HU18Z52J227056

how can i take those results and make a service that autofills my textboxes ???

Lucius, when i use ur code i lose my whole page, i cant reference something that isnt there anymore, can SOMEONE PLEASE HELP ME.... ANYONE..??? :-(



What you have problem with are some really basic stuff... We can try to help you but no one will give you a full working solution - it's something you need to do.

The page form is not displayed because you have "die();" function, remove that and you will get the form back.

As for passing the values to form textboxes use:

$FORM_NAME->TEXTBOX_NAME->SetValue($YOUR_VALUE_VARIABLE);

All you are struggling with is very well documented in CCS help, for example, in CCS press F1 and see:
Examples and techniques -> Programming -> Dynamically modifying HTML output -> Change Control Value
View profile  Send private message
DataDoIT
Posted: 12/05/2012, 5:03 AM

One of the things that helped me tremendously when I first started
CodeCharging was utilizing the 'paid' services of a couple of members of
this forum. From that I was able to compile quite an extensive library
of routines to various problems to get me up and running quickly and
efficiently. Looking back on the income that has been generated from
projects created, the costs of getting there are pennies on the dollar.

Value your own time and compare it to the costs of outsourcing some of
the solutions that you need.
SecureCloud


Posts: 51
Posted: 12/05/2012, 6:38 AM

Lucius & DataDoIT, bannedone
Thank you for your help, i really do appreciate it, i understand no one is gonna gimme a working solution, i dont expect that.

Lucius, i did remove the die(), and the page was still gone, once the button is clicked, everything is gone.

Quote :
All you are struggling with is very well documented in CCS help, for example, in CCS press F1 and see: Examples and techniques -> Programming -> Dynamically modifying HTML output -> Change Control Value
i have read all that, and ALOT more in 3 weeks, but when my FORM disappears, theres nothing to reference, i even tried include, nothing.


_________________
-------------------------------------------------------------------------------------------------
If this helped You, Please Donate to SecureCloud Here, ANY amount Accepted.
http://securecloud.biz/donate/
Thank You, Your help Keeps us Going.

View profile  Send private message
Lucius

Posts: 220
Posted: 12/05/2012, 7:42 AM

When I use your sample page http://sms.securecloud.biz/test1/cars_edit.php when I simply click Button1 I see the echo output, when I enter some number which is random (incorrect), you have an error - you will need to handle this.

When I enter your VIN (1D7HU18Z52J227056) I get the proper info in form of text output.

So it looks like so far so good.

Now for the last step - if you directly set the value of textbox in the event you are now using - this will not work, because those textboxes are still textboxes from when you clicked the button. What you see after page refresh are new textboxes - you need to fill those.

In the OnClick event of your Calculate button (make sure that in his properties operation selected is "Search", I think empty value should also work, also you should disable automatic validation of this button - the "enable validation property") save session variables for the fields, you wish to fill like so:

  
$var1 = 'YOUR_VALUE';  //this is just example, for you it will be the data you fetched from VIM page  
CCSetSession("my_session_var_name",$var1);  

Now select the page you have created in CCS and add Custom Code on After Initialize event.

In this event you can now feed the values you have saved in session:

  
global $MY_FORM;  
$var_from_session = CGetSession("my_session_var_name");  
$MY_FORM->MY_TEXTBOX->SetValue($var_from_session);

This should populate the textboxes.

You will need to of course to also program what happens in event when the VIN is not found, etc...
View profile  Send private message
SecureCloud


Posts: 51
Posted: 12/05/2012, 8:22 AM

the site i am using to decode vins is real, random numbers will not work, the way it breaks down the vin each set of numbers means something.

but error trapping is needed.


_________________
-------------------------------------------------------------------------------------------------
If this helped You, Please Donate to SecureCloud Here, ANY amount Accepted.
http://securecloud.biz/donate/
Thank You, Your help Keeps us Going.

View profile  Send private message
SecureCloud


Posts: 51
Posted: 12/05/2012, 12:57 PM

***NOTE

Thank all of you for your help....

I used bannedone, (John's) services, he knew exactly what he was doing and it was worth every penny...

if anyone needs help i strongly recommend him - http://realsites.biz/

and here is his member profile... http://forums.yessoftware.com/member.php?user_id=97479

Now i am FINALLY past that point.

AGAIN, thank you all....


_________________
-------------------------------------------------------------------------------------------------
If this helped You, Please Donate to SecureCloud Here, ANY amount Accepted.
http://securecloud.biz/donate/
Thank You, Your help Keeps us Going.

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.