This topic is locked
[SOLVED]

 Custom Button and $param - totally lost....

5/26/2011 10:15:47 AM
PHPRunner General questions
M
mickna author

After a whole day try and error, I am lost <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=17097&image=1&table=forumtopics' class='bbc_emoticon' alt=':(' />
Situation:

On "View Page" I added a custom Button to redirect me to another page (to add). No big deal. Now I try the whole day to grab some field values and have them available on the add page.
Also found a thread regarding this issue here, but unfortunately it does not work for me....
Firebug:

document.forms.editform1 is undefined
Button Properties:

"Client before" tab

params["txt"] = document.forms.editform1.value_from_id_1.value;



Where "from_id" is a field name from the displayed table and holds a number
"Server" tab

$_SESSION["FromID"] = $params["txt"];


"Client after" tab

location.href="anotherSiteSend_add.php";


Any idea, why my document.forms.editform1.value_from_id_1.value did not work for me?
thx,

mickna

Sergey Kornilov admin 5/26/2011

You need to use Javascript API to access any specific field value.
More info:

http://xlinesoft.com/phprunner/docs/javascript_api.htm

http://xlinesoft.com/phprunner/docs/ctrl_getvalue.htm

M
mickna author 5/27/2011

Did not work at all.

You know, I use a button and would like to use "Button properties"?
If I only use this example to do a simple check if your examples will work:

//Inserted in Button properties - Client before

var ctrl = Runner.getControl(pageid, 'from_id'); //from_id is the field name which value I want to grab

var value = ctrl.getValue();


Firebug tells me:

ctrl.getValue is not a function
I am also wondering, why this solution not work for me (see my first posting)...
Is it really so difficult to store a field value in a variable to use it at another page using Buttons?....
Help would be really nice...

Thanks,

mickna

J
Jane 5/27/2011

Hi,
It's difficult to tell you what's happening without seeing actual files.
Please publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.
The code from this thread (http://www.asprunner.com/forums/topic/14923-insert-button-feature-to-update-field-during-add-page/) doesn't work because this code is for PHPRunner 5.2. There is no form on the add/edit pages in PHPRunner 5.3, forms are created dynamically so you should use JavaScript API to return field value, not document.getElementById() statement.

M
mickna author 5/27/2011

Hi Jane,
nice to talk to you <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=58572&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />
No problem, I can upload the project.

However, I also do not want to waste your time. It sounds to be a simple task:

  • I am working on my private message system.
  • A user send a private message to another user (works fine)
  • the recipient reads the message (view page)
  • I have add a custom button on view page with "replay to sender"
  • This button redirects to the "add page" so the recipient can fill out the next message as answer to the first one
  • What I want to have: I not only want to redirect to the add page, I also want to grab the senders name from the view page and auto fill it in the add page. This way a replay makes sense. Recipient press "replay to sender" and see in the add page the senders name as new recipient.
    Or in other words: If the example from you was for PR 5.2 -> How can I achieve exact this example with PR 5.3?
    Thank you for your time and great support,

    mickna

J
Jane 5/27/2011

Hi,
I see what you're saying. getControl() function works on the add and edit pages only.

Here is a sample code for the view page:

  1. select value from database on the Servertab:

global $dal;

$dal_table = $dal->Table("TableName");

$rstmp = $dal_table->Query("KeyField=".$keys["KeyField"],"");

$datatmp = db_fetch_array($rstmp);

$result["txt"] = $datatmp["FieldName"];



2. pass selected value to the Client after tab:

window.location.href='TableName2_add.php?FieldName='+result["txt"];

return;



Then you can save $_REQUEST["FieldName"] in the session variable in the Add page: Before process event and use it as default value on the "Edit as" settings dialog.

M
mickna author 5/27/2011

Hi Jane,
thank you so much.

I will test it later. I have now set up a workaround and store the value via "view as - Custom" and set there a $_SESSION with the necessary data.
Again thank you,

mickna

M
mickna author 5/27/2011

Heck, I am frustrated and opened a ticket #233855