This topic is locked

increase/decrease button on an inline edit field

6/26/2010 6:02:40 AM
PHPRunner General questions
A
aptivus author

Dear Phprunner users /admins,

I am successfully running your software for a business application of mine, but now

i would really appreciate to increase its usability.

Therefore I am asking whether you could suggest how to modify an inline edit

numeric field in order to show by its side 2 arrow buttons (increase, decrease) just

like Joomla does to sort the elements (articles, sections, categories..).

I would like to give the same feature to my application, so the buttons should increase or

decrease by 1.

You see the image attached for a better explanation.


Any suggestion about that?

Thanks a lot.

A
aptivus author 6/26/2010

I have found this js script surfing the web:

<script type=text/javascript>

// Quantity spin buttons

function increase_by_one(field) {

nr = parseInt(document.getElementById(field).value);

document.getElementById(field).value = nr + 1;

}
function decrease_by_one(field) {

nr = parseInt(document.getElementById(field).value);

if (nr > 0) {

if( (nr - 1) > 0) {

document.getElementById(field).value = nr - 1;

}

}

}

</SCRIPT>


Then I assign an onclick event to the arrows like so:

<A title="increase value" onclick="increase_by_one('HERE GOES THE PARAMETER');" href="#reorder">

<IMG border=0 alt="increse arrow" src="images/uparrow.png" width=16 height=16>

</A>


As to the parameter, given that the name of my field is: ordinamento

than I don't know how to assign the proper combination myfield_value+id_row_to_edit that is proper of PHPRunner.

Example:

the parameter should be: value_ordinamento_4 where 4 is the row number to be edited.

I have tried assigning manually and it works (just for one row).
Then I've tried putting it this way: valueordinamento{$id_cat_value}

where {$id_cat_value} should be the value of the autoincrement record, but nothing.

All I get is a blank space like so:
How to go on to make this script suitable for all the rows?

You experts have a lead?

Thank you very much.

A
ann 6/28/2010

Hi,
you need to add some {$custom_link} here:

onclick="increase_by_one({$custom_link});"


Then define it in the After record processed event on the Events tab.

Here is a sample:

$record["custom_link"]=...;



Current record values are in the $data array.

A
aptivus author 6/29/2010

Thank you Ann.

I'll try it the soonest.

Z
Zane 7/6/2010

Nice job.Keep on going...
london carpenter