Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie! -Stumped on popUpMenu Code

Status
Not open for further replies.

gkromjr

Technical User
Dec 12, 2004
6
US
Hello,
I need to be able to choose an item from the menu by clicking it and have a field populated. An example would be used in a file name of demo.pdf the fieldname is "race" and I need to click on White and have the letter "W" populate the field and then have the curser move to the next field.
I could only figure out the popUpMenu that is dead. Hope it can be done.
Thanks
Code:
var reply=app.popUpMenu(
"OFFICER'S RACE",
"-",
"White = W",
"Black = B",
"American Indian/Alaskan Native = I",
"Asian/Pacific Islander = A",
"Other = O",
"Unknown = U");
 
Are you looking for code that pops up a new window with a dropdown (select) box with the supplied options? Or does app.popUpMenu mean you are using indesign scripting? Or is app something else?

--Chessbot

There is a level of Hell reserved for probability theorists in which every monkey that types on a typewriter produces a Shakespearean sonnet.
 
I am looking for help with a new window with a dropdown (select) box with the supplied options. When the option is selected it will populate the field. Then the window will disappear and the curser will tab to the next field.

 
So something like this?
Code:
var t = null;

function popWindow(title, texts, values, target)
{
/* Explanation of arguments:
title = title of window, page
texts = an array of the appearances of the windows
values = an array containing the values corresponding to texts
target = form field (or something) whose value is to be set
*/

  t = target;

  var win = window.open("", "_blank", "width=200, height=100, status=no");
  with (win.document)
  {
    open();
    writeln("<html>");
    writeln("<head>");
    writeln("<title>" + title + "</title>");
    writeln("</head>");
    writeln("<body>");
    writeln("<form>");
    writeln("<select name=\"s\">");
    for (var i=0; i<texts.length; i++)
      writeln("<option value=\"" + values[i] + "\">" + texts[i] + "</option>";
    writeln("</select>");
    writeln('<input type="button" value="OK" onclick="opener.setValue(this.form);">');
    writeln("</form>");
    writeln("</body>");
    writeln("</html>");
  }
}

function setValue(f)
{
  var s = f.elements['s'];
  t.value = s.options[s.selectedIndex].value;
}
(Untested...)

--Chessbot

There is a level of Hell reserved for probability theorists in which every monkey that types on a typewriter produces a Shakespearean sonnet.
 
Thanks for the help Chessbot, Unfortunately when I enter my arguments and insert it in abobe as a button it won't work.
 
Oh, so you are using adobe... Sorry, no experience there.

--Chessbot

There is a level of Hell reserved for probability theorists in which every monkey that types on a typewriter produces a Shakespearean sonnet.
 
Insert it in Adobe" ??

If you're trying to write Adobe Acrobat JavaScript, you need to post in the Acrobat forum. The Acrobat DOM is completely different than the Web/Browser DOM. There are no window objects in Acrobat, for example.

For dynmically popuplating a PDF with server-generated FDF, see my code in the thread: thread223-756675.

If that doesn't work, let me know. I can help you add menu items dynamically to Acrobat, tied to JavaScript that will populate forms, etc.

In any case, I think the Acrobat forum is where you need to be. The "JavaScript" discussed here is for client-side web development.


Thomas D. Greer

Providing PostScript & PDF
Training, Development & Consulting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top