• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

message box with yes no

Participant ,
Mar 06, 2018 Mar 06, 2018

Copy link to clipboard

Copied

I have a checkbox, when you click it a message appears. Asks you a question, if you click yes, mesage goes away and checkbox is checked. If you click no, the message goes away and box is not checked.

I found this, I just need to conditional Yes No?

I use Acrobat XI

https://acrobatusers.com/forum/forms-livecycle-designer/message-box-forms-using-checkbox/

TOPICS
PDF forms

Views

5.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Mar 06, 2018 Mar 06, 2018

Copy link to clipboard

Copied

Use this code as the field's MouseUp event:

event.target.checkThisBox(0, app.alert("Check this box?",2,2)==4);

View solution in original post

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 06, 2018 Mar 06, 2018

Copy link to clipboard

Copied

Use this code as the field's MouseUp event:

event.target.checkThisBox(0, app.alert("Check this box?",2,2)==4);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 06, 2018 Mar 06, 2018

Copy link to clipboard

Copied

your the best.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 06, 2018 Mar 06, 2018

Copy link to clipboard

Copied

Hi, on the formatting, I used a /n for a return, to put space before the question. Actually used 2 before 'Do you have an additional sheet. works good

I also want 2 returns after 'Section # 2: Conditions for cultivation' but the /n /n shows up on the message? and does not give a return?

event.target.checkThisBox(0, app.alert("Section # 2: Conditions for cultivation /n /n Mark with a cross if additional information is given on an attached sheet. \n \n Do you have an additional sheet?",2,2)==4);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 06, 2018 Mar 06, 2018

Copy link to clipboard

Copied

It's "\n", not "/n"...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 06, 2018 Mar 06, 2018

Copy link to clipboard

Copied

perfect, thank you.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 06, 2018 Mar 06, 2018

Copy link to clipboard

Copied

when trying to mark you correct, I get this. I refreshed and I am logged in? I will log out and back in to try.

Your content could not be saved due to an error. You may have been logged out. If this problem persists please contact your system administrator. Click here to refresh this page.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 06, 2018 Mar 06, 2018

Copy link to clipboard

Copied

There seems to be some issues with the servers at the moment... Try again later.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 28, 2019 May 28, 2019

Copy link to clipboard

Copied

I'd like to add this as a document level script. This is what I have for the targeted field.

if(this.getfield("Expense.valueasstring")=="Per Diem" && event.value>0){

TravelDay("ExpRow1Col1.0");}

I mod'd your script to make function for doc lvl but overall it's not working.

function TravelDay()

{event.target.checkThisBox(0, app.alert("Is this the first or last day of your travel?",2,2, "Travel Day")==4);

if(nRslt == 4) {event.value=event.value*0.75;

}}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 28, 2019 May 28, 2019

Copy link to clipboard

Copied

There are a lot of errors in your code. What are you trying to achieve, exactly?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 28, 2019 May 28, 2019

Copy link to clipboard

Copied

I fixed a little bit of it. But the current field displays the wrong value and exports the raw value. So basically I put the value of 100 in field C an alert pops up asking for a yes/no response. if yes is selected then the event.value = event.value*.75 to give a result of 75.

Document Level

function TravelDay()

{event.target.checkThisBox( app.alert("Is this the first or last day of your travel?",2,2, "Travel Day"));

if(nRslt == 4) {

newtotal= event.value*0.75;

event.value=newtotal

}

Current Field

var A = this.getField("Expense");

var B = (A).value;  

var C = (A).currentValueIndices;

if(C=4 && event.value>0){

TravelDay("ExpRow1Col1.0");}

Right now I'm only getting the raw value. But when user selects "yes" I should get value times 75%

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 28, 2019 May 28, 2019

Copy link to clipboard

Copied

Where does you set the value of nRslt?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 28, 2019 May 28, 2019

Copy link to clipboard

Copied

when the user selects yes on the app.alert.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 28, 2019 May 28, 2019

Copy link to clipboard

Copied

actually return value is 3 not 4. I just changed it and still no good

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 28, 2019 May 28, 2019

Copy link to clipboard

Copied

You're code is still filled with errors. besides the "nRslt" error that Bernd points out. What is this code supposed to do?

event.target.checkThisBox( app.alert("Is this the first or last day of your travel?",2,2, "Travel Day"));

When writing code for the first time you need to start small. Just get one little thing to work and build from there so you can learn about the environment and the programming language. 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 29, 2019 May 29, 2019

Copy link to clipboard

Copied

LATEST

Yea I don't normally JavaScript as you can tell. I piecemeal scripts together mostly. I should've caught that nRslt myself. Anyway, I've tried to get it working and when I would fix one thing I would notice another issue. Basically I was trying to make it so when a person selects the drop down of "Per Diem" then in the next field when they input their amount. it would popup asking if it was the first or last day of travel. If they select "yes" it would calculate 75% "no" would be no change in value. Or something to that effect. Kinda worked with this but there was others issues with having it at doc lvl. like recalculating the percentage even when the said field wasn't the focus.

function TravelDay(fields, ignoreBlanks, ignoreZeros) { 

   var total = 0

   var ntotal = 0;

    var n = 0;

   var v = 0;

   var nRslt = (app.alert("Is this the first or last day of your travel?",2,2, "Travel Day"));

    for (var i in fields) { 

   var f = this.getField(fields[i]); 

   if (f===null) { 

   console.println("Error! Can't locate a field called: " + fields[i]); 

   continue

  } 

   if (f.valueAsString==="" && ignoreBlanks) continue

   if (Number(f.valueAsString)===0 && ignoreZeros) continue

   total+=Number(f.valueAsString);

        ntotal=((total).toFixed(3));

   v = total*0.75;

  

        n++;

  } 

   if (nRslt=3) event.value = v;

   else if (nRslt!=3)event.value = total;

   else event.value="";

  

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 28, 2019 May 28, 2019

Copy link to clipboard

Copied

I can't see nRslt = ???

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines