[SalesForce] Passing user parameters to a button

I'm trying to pass user parameters (integers) to a button, which runs a method. At the moment, my method and button work as intended, except with hard coded data.

Below is an image of what I'm trying to do. Is there anyway to create a text field like this that will send data to my function? I'm quite new to Salesforce, and would appreciate any feedback.

(for more reference as to what I'm trying to do, my button will copy/create new assignments for however many months into the future as the user selects)

enter image description here

EDIT

The below is what my javascript code now looks like:

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")}
var timestoexecute = prompt("Please enter how many months to copy this assignment over", "1");

var result = sforce.apex.execute("AssignmentPropagation","copyAssignments",{assignmentName:"{!Assignment__c.Name}", times:timestoexecute});
alert(result);
window.location.reload();

By adding a prompt, and sending that variable to the Apex class, I now get the desired results. Thanks Daniel.

Best Answer

You can't place additional controls next to the custom buttons. At least without using some form of JavaScipt DOM injection, which could create bigger problems.

There are a few options I can think of:

  1. Create an intermediate Visualforce page that collects the parameter data
  2. Use an "Execute JavaScript" button to prompt for the extra parameter before performing the action.
  3. Inline a Visualforce page into the page layout that has all the controls you need.

Aptorian's implementation of option 2:

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")}
var timestoexecute = prompt("Please enter how many months to copy this assignment over", "1");

var result = sforce.apex.execute("AssignmentPropagation","copyAssignments",{assignmentName:"{!Assignment__c.Name}", times:timestoexecute});
alert(result);
window.location.reload();

By adding a prompt, and sending that variable to the Apex class, I now get the desired results.