Need help with a form calculation

I am trying to create a form in Acrobat that will support a calculation of percentages. I have the
following formula:
if (a1.value == "" || a1.value == "" && b1.value == "") {c1=0} else {b1/a1}
The percentage is not calculating and is remaining at 0% when numbers are entered on the form. I am trying to avoid the error messages we receive if we just enter the basic calculation in to the simplified (because some of the cells may have a value of 0).
Can anyone help?

Try this:
// Get the field values
var v1 = getField("a1").value;
var v2 = getField("b1").value;
//. Perform the calculation
if (v1) {
    event.value = v2 / v1;
} else {
    event.value = 0;
Edit: corrected typo

Similar Messages

  • [8i] Need help with some workday calculations

    At the beginning of the month, I got help with a workday calculation in: [8i] Help with function with parameters (for workday calculation)
    Now, as it turns out, I was able to locate a function in the database that does what I want, however, it is much slower to use the function than to join two copies of the CALN table (Please see referenced thread for details. I can copy them to this thread if necessary.) I need to verify that the pre-existing function has 'DETERMINISTIC' in it, as I would guess that if it doesn't, it would be much slower than it could be.
    But now, I've come across a situation where I have to do multiple workday calculations in the same query--enough that I have to join 6 copies of my CALN table. I can't imagine that is at all efficient. I believe it was Frank K. who said (in the original thread) that if the function was slow, I should consider alternatives. Can anyone help me identify some of those alternatives? I'm definitely at that point now. (This query is one I'm using as the base for a report in Oracle BI, and let's just say it doesn't like my query, even though my syntax appears to be correct, and I would guess that joining 6 copies of one table is at least partly to blame for this).
    Note: I'm working with Oracle 8i

    OK, I finally have some sample data... I tried to make it thorough. I've included data in the CALN table YTD + tomorrow, so that any workday calculations using SYSDATE will work.
    CREATE TABLE caln
    (     clndr_dt     DATE          NOT NULL
    ,     clndr_yr     NUMBER
    ,     shop_day     NUMBER
    ,     shop_dt          DATE
    ,     shop_wk          NUMBER
    ,     shop_yr          NUMBER
    ,     shop_days     NUMBER
    ,     clndr_days     NUMBER
         CONSTRAINT caln_pk PRIMARY KEY (clndr_dt)
    INSERT INTO     caln
    VALUES (To_Date('12/23/2009','mm/dd/yyyy'),2009,247,To_Date('12/23/2009','mm/dd/yyyy'),51,2009,7631,10950);
    INSERT INTO     caln
    VALUES (To_Date('01/01/2010','mm/dd/yyyy'),2010,0,To_Date('12/23/2009','mm/dd/yyyy'),52,2009,7631,10959);
    INSERT INTO     caln
    VALUES (To_Date('01/02/2010','mm/dd/yyyy'),2010,0,To_Date('12/23/2009','mm/dd/yyyy'),52,2009,7631,10960);
    INSERT INTO     caln
    VALUES (To_Date('01/03/2010','mm/dd/yyyy'),2010,0,To_Date('12/23/2009','mm/dd/yyyy'),1,2010,7631,10961);
    INSERT INTO     caln
    VALUES (To_Date('01/04/2010','mm/dd/yyyy'),2010,1,To_Date('01/04/2010','mm/dd/yyyy'),1,2010,7632,10962);
    INSERT INTO     caln
    VALUES (To_Date('01/05/2010','mm/dd/yyyy'),2010,2,To_Date('01/05/2010','mm/dd/yyyy'),1,2010,7633,10963);
    INSERT INTO     caln
    VALUES (To_Date('01/06/2010','mm/dd/yyyy'),2010,3,To_Date('01/06/2010','mm/dd/yyyy'),1,2010,7634,10964);
    INSERT INTO     caln
    VALUES (To_Date('01/07/2010','mm/dd/yyyy'),2010,4,To_Date('01/07/2010','mm/dd/yyyy'),1,2010,7635,10965);
    INSERT INTO     caln
    VALUES (To_Date('01/08/2010','mm/dd/yyyy'),2010,5,To_Date('01/08/2010','mm/dd/yyyy'),1,2010,7636,10966);
    INSERT INTO     caln
    VALUES (To_Date('01/09/2010','mm/dd/yyyy'),2010,0,To_Date('01/08/2010','mm/dd/yyyy'),1,2010,7636,10967);
    INSERT INTO     caln
    VALUES (To_Date('01/10/2010','mm/dd/yyyy'),2010,0,To_Date('01/08/2010','mm/dd/yyyy'),2,2010,7636,10968);
    INSERT INTO     caln
    VALUES (To_Date('01/11/2010','mm/dd/yyyy'),2010,6,To_Date('01/11/2010','mm/dd/yyyy'),2,2010,7637,10969);
    INSERT INTO     caln
    VALUES (To_Date('01/12/2010','mm/dd/yyyy'),2010,7,To_Date('01/12/2010','mm/dd/yyyy'),2,2010,7638,10970);
    INSERT INTO     caln
    VALUES (To_Date('01/13/2010','mm/dd/yyyy'),2010,8,To_Date('01/13/2010','mm/dd/yyyy'),2,2010,7639,10971);
    INSERT INTO     caln
    VALUES (To_Date('01/14/2010','mm/dd/yyyy'),2010,9,To_Date('01/14/2010','mm/dd/yyyy'),2,2010,7640,10972);
    INSERT INTO     caln
    VALUES (To_Date('01/15/2010','mm/dd/yyyy'),2010,10,To_Date('01/15/2010','mm/dd/yyyy'),2,2010,7641,10973);
    INSERT INTO     caln
    VALUES (To_Date('01/16/2010','mm/dd/yyyy'),2010,0,To_Date('01/15/2010','mm/dd/yyyy'),2,2010,7641,10974);
    INSERT INTO     caln
    VALUES (To_Date('01/17/2010','mm/dd/yyyy'),2010,0,To_Date('01/15/2010','mm/dd/yyyy'),3,2010,7641,10975);
    INSERT INTO     caln
    VALUES (To_Date('01/18/2010','mm/dd/yyyy'),2010,11,To_Date('01/18/2010','mm/dd/yyyy'),3,2010,7642,10976);
    INSERT INTO     caln
    VALUES (To_Date('01/19/2010','mm/dd/yyyy'),2010,12,To_Date('01/19/2010','mm/dd/yyyy'),3,2010,7643,10977);
    INSERT INTO     caln
    VALUES (To_Date('01/20/2010','mm/dd/yyyy'),2010,13,To_Date('01/20/2010','mm/dd/yyyy'),3,2010,7644,10978);
    INSERT INTO     caln
    VALUES (To_Date('01/21/2010','mm/dd/yyyy'),2010,14,To_Date('01/21/2010','mm/dd/yyyy'),3,2010,7645,10979);
    INSERT INTO     caln
    VALUES (To_Date('01/22/2010','mm/dd/yyyy'),2010,15,To_Date('01/22/2010','mm/dd/yyyy'),3,2010,7646,10980);
    INSERT INTO     caln
    VALUES (To_Date('01/23/2010','mm/dd/yyyy'),2010,0,To_Date('01/22/2010','mm/dd/yyyy'),3,2010,7646,10981);
    INSERT INTO     caln
    VALUES (To_Date('01/24/2010','mm/dd/yyyy'),2010,0,To_Date('01/22/2010','mm/dd/yyyy'),4,2010,7646,10982);
    INSERT INTO     caln
    VALUES (To_Date('01/25/2010','mm/dd/yyyy'),2010,16,To_Date('01/25/2010','mm/dd/yyyy'),4,2010,7647,10983);
    INSERT INTO     caln
    VALUES (To_Date('01/26/2010','mm/dd/yyyy'),2010,17,To_Date('01/26/2010','mm/dd/yyyy'),4,2010,7648,10984);
    INSERT INTO     caln
    VALUES (To_Date('01/27/2010','mm/dd/yyyy'),2010,18,To_Date('01/27/2010','mm/dd/yyyy'),4,2010,7649,10985);
    INSERT INTO     caln
    VALUES (To_Date('01/28/2010','mm/dd/yyyy'),2010,19,To_Date('01/28/2010','mm/dd/yyyy'),4,2010,7650,10986);
    INSERT INTO     caln
    VALUES (To_Date('01/29/2010','mm/dd/yyyy'),2010,20,To_Date('01/29/2010','mm/dd/yyyy'),4,2010,7651,10987);
    INSERT INTO     caln
    VALUES (To_Date('01/30/2010','mm/dd/yyyy'),2010,0,To_Date('01/29/2010','mm/dd/yyyy'),4,2010,7651,10988);
    INSERT INTO     caln
    VALUES (To_Date('01/31/2010','mm/dd/yyyy'),2010,0,To_Date('01/29/2010','mm/dd/yyyy'),5,2010,7651,10989);
    INSERT INTO     caln
    VALUES (To_Date('02/01/2010','mm/dd/yyyy'),2010,21,To_Date('02/01/2010','mm/dd/yyyy'),5,2010,7652,10990);
    INSERT INTO     caln
    VALUES (To_Date('02/02/2010','mm/dd/yyyy'),2010,22,To_Date('02/02/2010','mm/dd/yyyy'),5,2010,7653,10991);
    INSERT INTO     caln
    VALUES (To_Date('02/03/2010','mm/dd/yyyy'),2010,23,To_Date('02/03/2010','mm/dd/yyyy'),5,2010,7654,10992);
    INSERT INTO     caln
    VALUES (To_Date('02/04/2010','mm/dd/yyyy'),2010,24,To_Date('02/04/2010','mm/dd/yyyy'),5,2010,7655,10993);
    INSERT INTO     caln
    VALUES (To_Date('02/05/2010','mm/dd/yyyy'),2010,25,To_Date('02/05/2010','mm/dd/yyyy'),5,2010,7656,10994);
    INSERT INTO     caln
    VALUES (To_Date('02/06/2010','mm/dd/yyyy'),2010,0,To_Date('02/05/2010','mm/dd/yyyy'),5,2010,7656,10995);
    INSERT INTO     caln
    VALUES (To_Date('02/07/2010','mm/dd/yyyy'),2010,0,To_Date('02/05/2010','mm/dd/yyyy'),6,2010,7656,10996);
    INSERT INTO     caln
    VALUES (To_Date('02/08/2010','mm/dd/yyyy'),2010,26,To_Date('02/08/2010','mm/dd/yyyy'),6,2010,7657,10997);
    INSERT INTO     caln
    VALUES (To_Date('02/09/2010','mm/dd/yyyy'),2010,27,To_Date('02/09/2010','mm/dd/yyyy'),6,2010,7658,10998);
    INSERT INTO     caln
    VALUES (To_Date('02/10/2010','mm/dd/yyyy'),2010,28,To_Date('02/10/2010','mm/dd/yyyy'),6,2010,7659,10999);
    INSERT INTO     caln
    VALUES (To_Date('02/11/2010','mm/dd/yyyy'),2010,29,To_Date('02/11/2010','mm/dd/yyyy'),6,2010,7660,11000);
    INSERT INTO     caln
    VALUES (To_Date('02/12/2010','mm/dd/yyyy'),2010,30,To_Date('02/12/2010','mm/dd/yyyy'),6,2010,7661,11001);
    INSERT INTO     caln
    VALUES (To_Date('02/13/2010','mm/dd/yyyy'),2010,0,To_Date('02/12/2010','mm/dd/yyyy'),6,2010,7661,11002);
    INSERT INTO     caln
    VALUES (To_Date('02/14/2010','mm/dd/yyyy'),2010,0,To_Date('02/12/2010','mm/dd/yyyy'),7,2010,7661,11003);
    INSERT INTO     caln
    VALUES (To_Date('02/15/2010','mm/dd/yyyy'),2010,31,To_Date('02/15/2010','mm/dd/yyyy'),7,2010,7662,11004);
    INSERT INTO     caln
    VALUES (To_Date('02/16/2010','mm/dd/yyyy'),2010,32,To_Date('02/16/2010','mm/dd/yyyy'),7,2010,7663,11005);
    INSERT INTO     caln
    VALUES (To_Date('02/17/2010','mm/dd/yyyy'),2010,33,To_Date('02/17/2010','mm/dd/yyyy'),7,2010,7664,11006);
    INSERT INTO     caln
    VALUES (To_Date('02/18/2010','mm/dd/yyyy'),2010,34,To_Date('02/18/2010','mm/dd/yyyy'),7,2010,7665,11007);
    INSERT INTO     caln
    VALUES (To_Date('02/19/2010','mm/dd/yyyy'),2010,35,To_Date('02/19/2010','mm/dd/yyyy'),7,2010,7666,11008);
    INSERT INTO     caln
    VALUES (To_Date('02/20/2010','mm/dd/yyyy'),2010,0,To_Date('02/19/2010','mm/dd/yyyy'),7,2010,7666,11009);
    CREATE TABLE ords
    (     ord_nbr          NUMBER          NOT NULL
    ,     sub_nbr          NUMBER          NOT NULL
    ,     ord_stat     VARCHAR2(2)
    ,     ord_qty          NUMBER
    ,     part_nbr     VARCHAR2(5)
         CONSTRAINT ords_pk PRIMARY KEY (ord_nbr, sub_nbr)
    INSERT INTO     ords
    VALUES (1,1,'CL',10,'PART1');
    INSERT INTO     ords
    VALUES (1,2,'CL',5,'PART1');
    INSERT INTO     ords
    VALUES (25,1,'CL',15,'PART2');
    INSERT INTO     ords
    VALUES (14,1,'OP',12,'PART3');
    INSERT INTO     ords
    VALUES (33,1,'CL',25,'PART1');
    INSERT INTO     ords
    VALUES (33,2,'CL',15,'PART1');
    INSERT INTO     ords
    VALUES (33,3,'OP',10,'PART1');
    INSERT INTO     ords
    VALUES (7,1,'PL',18,'PART2');
    INSERT INTO     ords
    VALUES (96,1,'PL',10,'PART3');
    INSERT INTO     ords
    VALUES (31,1,'CL',20,'PART2');
    CREATE TABLE oops
    (     ord_nbr          NUMBER          NOT NULL
    ,     sub_nbr          NUMBER          NOT NULL
    ,     op_nbr          VARCHAR2(4)     NOT NULL
    ,     mach_id          VARCHAR2(4)
    ,     oper_stat     VARCHAR2(2)
    ,     plan_start_dt     DATE
    ,     plsu          NUMBER
    ,     plrn          NUMBER
         CONSTRAINT ords_pk PRIMARY KEY (ord_nbr, sub_nbr, op_nbr)
    -- NOTE:
    -- for the orders with a status of 'CL' or 'PL' in the 'ords' table, I'm not bothering to put
    -- in more than two operations (though in reality more would be there) since they should be
    -- ignored in the final result anyway
    INSERT INTO     oops
    VALUES (1,1,'0010','123A','CL',TO_DATE('01/11/2010','mm/dd/yyyy'),2,0.2);
    INSERT INTO     oops
    VALUES (1,1,'0015','259B','CP',TO_DATE('01/12/2010','mm/dd/yyyy'),1,0.15);
    INSERT INTO     oops
    VALUES (1,2,'0010','123A','CP',TO_DATE('01/11/2010','mm/dd/yyyy'),2,0.2);
    INSERT INTO     oops
    VALUES (1,2,'0015','259B','CP',TO_DATE('01/12/2010','mm/dd/yyyy'),1,0.15);
    INSERT INTO     oops
    VALUES (25,1,'0005','123A','CP',TO_DATE('01/18/2010','mm/dd/yyyy'),2,0.25);
    INSERT INTO     oops
    VALUES (25,1,'0030','110C','CL',TO_DATE('01/19/2010','mm/dd/yyyy'),4,0.1);
    INSERT INTO     oops
    VALUES (14,1,'0010','127A','CP',TO_DATE('01/11/2010','mm/dd/yyyy'),2,0.25);
    INSERT INTO     oops
    VALUES (14,1,'0025','110C','CL',TO_DATE('01/12/2010','mm/dd/yyyy'),1,0.1);
    INSERT INTO     oops
    VALUES (14,1,'0040','050C','CP',TO_DATE('01/13/2010','mm/dd/yyyy'),1.3,0.15);
    INSERT INTO     oops
    VALUES (14,1,'0050','220B','WK',TO_DATE('01/14/2010','mm/dd/yyyy'),4,0.25);
    INSERT INTO     oops
    VALUES (14,1,'0065','242B','AV',TO_DATE('01/18/2010','mm/dd/yyyy'),1.5,0.1);
    INSERT INTO     oops
    VALUES (14,1,'0067','150G','NA',TO_DATE('01/19/2010','mm/dd/yyyy'),2,0.1);
    INSERT INTO     oops
    VALUES (14,1,'0100','250G','NA',TO_DATE('01/20/2010','mm/dd/yyyy'),2.1,0.2);
    INSERT INTO     oops
    VALUES (33,1,'0010','123A','CL',TO_DATE('01/11/2010','mm/dd/yyyy'),1.9,0.2);
    INSERT INTO     oops
    VALUES (33,1,'0015','259B','CP',TO_DATE('01/12/2010','mm/dd/yyyy'),1,0.1);
    INSERT INTO     oops
    VALUES (33,2,'0010','123A','CL',TO_DATE('01/11/2010','mm/dd/yyyy'),1.9,0.2);
    INSERT INTO     oops
    VALUES (33,2,'0015','259B','CP',TO_DATE('01/12/2010','mm/dd/yyyy'),1,0.1);
    INSERT INTO     oops
    VALUES (33,3,'0010','123A','CL',TO_DATE('01/11/2010','mm/dd/yyyy'),1.9,0.2);
    INSERT INTO     oops
    VALUES (33,3,'0015','259B','CP',TO_DATE('01/12/2010','mm/dd/yyyy'),1,0.1);
    INSERT INTO     oops
    VALUES (33,3,'0020','220B','NA',TO_DATE('01/12/2010','mm/dd/yyyy'),1.7,0.15);
    INSERT INTO     oops
    VALUES (33,3,'0030','150G','NA',TO_DATE('01/13/2010','mm/dd/yyyy'),1.3,0.05);
    INSERT INTO     oops
    VALUES (33,3,'0055','150G','NA',TO_DATE('01/15/2010','mm/dd/yyyy'),2.1.,0.1);
    INSERT INTO     oops
    VALUES (7,1,'0005','123A','NA',TO_DATE('01/11/2010','mm/dd/yyyy'),2,0.2);
    INSERT INTO     oops
    VALUES (7,1,'0030','110C','NA',TO_DATE('01/12/2010','mm/dd/yyyy'),1,0.15);
    INSERT INTO     oops
    VALUES (96,1,'0010','127A','NA',TO_DATE('01/11/2010','mm/dd/yyyy'),2,0.25);
    INSERT INTO     oops
    VALUES (96,1,'0025','110C','NA',TO_DATE('01/12/2010','mm/dd/yyyy'),1,0.1);
    INSERT INTO     oops
    VALUES (31,1,'0005','123A','CL',TO_DATE('01/11/2010','mm/dd/yyyy'),1.9,0.2);
    INSERT INTO     oops
    VALUES (31,1,'0030','110C','CP',TO_DATE('01/12/2010','mm/dd/yyyy'),1,0.1);
    CREATE TABLE mach
    (     mach_id          VARCHAR2(4)     NOT NULL
    ,     desc_short     VARCHAR2(9)     
    ,     group          VARCHAR2(7)
         CONSTRAINT ords_pk PRIMARY KEY (mach_id)
    INSERT INTO     mach
    VALUES     ('123A','desc here','GROUPH1');
    INSERT INTO     mach
    VALUES     ('259B','desc here','GROUPH2');
    INSERT INTO     mach
    VALUES     ('110C','desc here','GROUPJ1');
    INSERT INTO     mach
    VALUES     ('050C','desc here','GROUPK2');
    INSERT INTO     mach
    VALUES     ('220B','desc here','GROUPH2');
    INSERT INTO     mach
    VALUES     ('242B','desc here','GROUPH2');
    INSERT INTO     mach
    VALUES     ('150G','desc here','GROUPL1');
    INSERT INTO     mach
    VALUES     ('250G','desc here','GROUPL2');
    INSERT INTO     mach
    VALUES     ('242B','desc here','GROUPH2');

  • Need help with my graphic calculator!!!

    Hello everybody!! I need help with my little program I made.... The problem is that I am unable to use to calculate but it is possible to compile the code!! What should I do?? Thanks in advance.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class Aritmetik extends JFrame implements ActionListener{
         private JLabel l1 = new JLabel("Tal1: ", JLabel.LEFT);
         private JLabel l2 = new JLabel("Tal2: ", JLabel.LEFT);
         private JLabel l3 = new JLabel("Resultat",JLabel.LEFT);
         private JLabel l4 = new JLabel(" ", JLabel.RIGHT);
         private JTextField t1 = new JTextField(" ",10);
         private JTextField t2 = new JTextField(" ",10);
         private JButton b1 = new JButton("+");
         private JButton b2 = new JButton("-");
         private JButton b3 = new JButton("*");
         private JButton b4 = new JButton("/");
         public Aritmetik(){
              Container v = getContentPane();
              v.setLayout(new GridLayout(5,2));
              v.add(l1);
              v.add(t1);
              v.add(l2);
              v.add(t2);
              v.add(b1);
              v.add(b2);
              v.add(b3);
              v.add(b4);
              v.add(l3);
              v.add(l4);
              b1.addActionListener(this);
              b2.addActionListener(this);
              b3.addActionListener(this);
              b4.addActionListener(this);
              pack();
              setVisible(true);
              setDefaultCloseOperation(EXIT_ON_CLOSE);
         public void actionPerformed(ActionEvent e){
              int tal1 = Integer.parseInt(t1.getText());
              int tal2 = Integer.parseInt(t2.getText());
                   if(e.getSource() == b1){
              if(t1.getText().equals("") || t2.getText().equals(""))
                                       JOptionPane.showMessageDialog(null, "Mata in tal!");
                   else{
                        l3.setText("Resultat ");
                   l4.setText(" " + (tal1+tal2));
                   else if(e.getSource() == b2){
                        int sub = tal1-tal2;
                        l4.setText(" " + (sub));
                   else if(e.getSource() == b3){
                        int multi = tal1*tal2;
                        l4.setText(" " + (multi));
                   else if(e.getSource() == b4){
                        int div = tal1/tal2;
                        l4.setText(" " + (div));
                   public static void main(String[] arg){
                   Aritmetik A =new Aritmetik();

    Here is your problem:
    public void actionPerformed(ActionEvent e){
      int tal1 = Integer.parseInt(t1.getText().trim());  // add the trim()
      int tal2 = Integer.parseInt(t2.getText().trim());  // add the trim()
      if(e.getSource() == b1){
        if(t1.getText().equals("") || t2.getText().equals(""))
          JOptionPane.showMessageDialog(null, "Mata in tal!");
        else{
          l3.setText("Resultat ");
          l4.setText(" " + (tal1+tal2));
      }... Better ...
    public void actionPerformed(ActionEvent e)  throws NumberFormatException {
      String tala = t1.getText().trim();
      String talb = t2.getText().trim();
      if ( tala == null  ||  "".equals(tala)  ||  talb == null  ||  "".equals(talb) ) {
        JOptionPane.showMessageDialog(null, "Mata in tal!");
        return();
      int tal1 = Integer.parseInt(tala);
      int tal2 = Integer.parseInt(talb);
      if(e.getSource() == b1){
        l3.setText("Resultat ");
        l4.setText(" " + (tal1+tal2));
      else if(e.getSource() == b2){
        int sub = tal1-tal2;
        l4.setText(" " + (sub));
      else if(e.getSource() == b3){
        int multi = tal1*tal2;
        l4.setText(" " + (multi));
      else if(e.getSource() == b4){
        int div = tal1/tal2;
        l4.setText(" " + (div));
    }Message was edited by:
    abillconsl

  • Need help with PHP form with checkboxes, radio buttons and file attachment

    Hi guys,
    I'm having a nightmare with this PHP form where a user can fill it in, attach a doc/pdf and submit. After trying to sort it out with previous code I've used, I've stripped it out and think I should just start again in the hope you geniuses can help!
    Here is the HTML of contact.php:
    <form action="" method="post" name="contact" id="contact">
        <p>Job Title:*<br />
        <input name="position" type="text" /></p>
        <p>Nationality:*<br />
        <select name="nationality">
          <option value="">-- select one --</option>
          <option value="Afghan">Afghan</option>
          <option value="Albanian">Albanian</option>
          <option value="Algerian">Algerian</option>
          <option value="Zambian">Zambian</option>
          <option value="Zimbabwean">Zimbabwean</option>
        </select>
        </p>
        <p>Which country are you currently living in?*<br />
        <select name="country">
        <option value="">-- select one --</option>
        <option value="United Kingdom">United Kingdom</option>
        <option value="Afghanistan">Afghanistan</option>
        <option value="Africa">Africa</option>
        <option value="Zambia">Zambia</option>
        <option value="Zimbabwe">Zimbabwe</option>
        </select>
        </p>
        <label class="radio" for="checkRight">Yes/No question?</label><br />
        <input class="radio" type="radio" name="right" value="Yes" /> Yes
        <input class="radio" type="radio" name="right" value="No" /> No
        <input class="radio" type="radio" name="right" value="N/A" /> Not applicable
        <p>Yes/No question?<br />
        <select name="continue">
        <option value="">-- select one --</option>
        <option value="Yes">Yes</option>
        <option value="No">No</option>
        </select>
        </p>
        <p>Select your resorts:<br />
        Resort 1<input name="res1" type="checkbox" value="Resort 1" />
        Resort 2<input name="res2" type="checkbox" value="Resort 2" />
        Resort 3<input name="res3" type="checkbox" value="Resort 3" />
        Resort 4<input name="res4" type="checkbox" value="Resort 4" />
        Resort 5<input name="res5" type="checkbox" value="Resort 5" />
        Resort 6<input name="res6" type="checkbox" value="Resort 6" />   
        </p>
        <p>Don't send form unless this is checked:* <input type="checkbox" name="parttime" value="Yes" /></p>
        <p>Date of arrival: <input name="arrive" id="datepick" /><br />
        Date of departure: <input name="depart" id="datepick2" /></p>
        <script type="text/javascript" src="assets/scripts/datepickr/datepickr.js"></script>
        <link href="assets/scripts/datepickr/datepickr.css" rel="stylesheet">
        <script type="text/javascript">
        new datepickr('datepick');
        new datepickr('datepick2', {
        </script>
        <p>Name:*<br />
        <input name="name" type="text" /></p>
        <p>E-mail:*<br />
        <input name="email" type="text" /></p>
        <p>Telephone:*<br />
        <input name="telephone" type="text" class="ctextField" /></p>
        <p>Upload CV (Word of PDF formats only):<br />
        <input type="file" name="cv" class="textfield"></p>
        <p><input name="submit" value="Submit Enquiry" class="submitButton" type="submit" /><div style="visibility:hidden; width:1px; height:1px"><input name="url" type="text" size="45" id="url" /></div></p>
    </form>
    By the way, the date boxes work so excuse the Javascript in there!
    To prevent SPAM I've used a trick where there's a hidden URL field which must be left blank for the form to submit which you can see in the PHP.
    Below is where I'm at with the PHP which is placed above the header of contact.php...
    <?php
    if (array_key_exists('submit', $_POST)) {
        $position = $_POST['position'];
        $arrive = $_POST['arrive'];
        $nationality = $_POST['nationality'];
        $parttime = $_POST['parttime'];
        $depart = $_POST['depart'];
        $name = $_POST['name'];
        $email = $_POST['email'];
        $telephone = $_POST['telephone'];
    $to = "[email protected]";
    $subject = "Recruitment Application";
    $message = $headers;
    $message .= "Name: " . $_POST["name"] . "\r\n";
    $message .= "E-mail: " . $_POST["email"] . "\r\n";
    $headers  = "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
    $headers .= "Reply-To: " . $_POST["email"] . "\r\n";
    $headers .= 'From: My Website <[email protected]>' . "\r\n";
    $message= "
    $url = stripslashes($_POST["url"]);
    if (!empty($url)) {
    header( 'Location: http://www.go-away-spam-robots.com' );
    exit();
    if (!isset($warning)) {
    mail($to, $subject, $message, $headers);
    header( 'Location: http://www.mywebsite.co.uk/sent.php' );
    ?>
    I would like to make pretty much all the field compulsory so if a field is left empty (other than the hidden URL field), a warning message is displayed next to that field.
    Also I would like the file upload field to attach to the email that is sent to me and have the results come through to me in a table format.
    Can anyone help me get my form working?
    Thank you and I hope to hear from you!
    SM

    Hi Nancy,
    Great stuff, thank you for the reply.
    I've managed to get the Formm@iler working and running as I need it to.
    The only thing I'm struggling with is when the user clicks submit, they are taken to a page of whatever results the form returned but it is just a white background with Times New Roman text.
    How can I have it so the user is taken to the form results in the websites' page layout?
    I tried sending them to a generic 'thank you' page by adding the following code but it just took them there whatever the results of the form so that's no good...! I have a feeling it's a bit more complicated than that...
    header( 'Location: http://www.nofussbus.co.uk/test/sent.php' );
    Thank you for your help!

  • I need help with this program ( Calculating Pi using random numbers)

    hi
    please understand that I am not trying to ask anymore to do this hw for me. I am new to java and working on the assignment. below is the specification of this program:
    Calculate PI using Random Numbers
    In geometry the ratio of the circumference of a circle to its diameter is known as �. The value of � can be estimated from an infinite series of the form:
    � / 4 = 1 - (1/3) + (1/5) - (1/7) + (1/9) - (1/11) + ...
    There is another novel approach to calculate �. Imagine that you have a dart board that is 2 units square. It inscribes a circle of unit radius. The center of the circle coincides with the center of the square. Now imagine that you throw darts at that dart board randomly. Then the ratio of the number of darts that fall within the circle to the total number of darts thrown is the same as the ratio of the area of the circle to the area of the square dart board. The area of a circle with unit radius is just � square unit. The area of the dart board is 4 square units. The ratio of the area of the circle to the area of the square is � / 4.
    To simuluate the throwing of darts we will use a random number generator. The Math class has a random() method that can be used. This method returns random numbers between 0.0 (inclusive) to 1.0 (exclusive). There is an even better random number generator that is provided the Random class. We will first create a Random object called randomGen. This random number generator needs a seed to get started. We will read the time from the System clock and use that as our seed.
    Random randomGen = new Random ( System.currentTimeMillis() );
    Imagine that the square dart board has a coordinate system attached to it. The upper right corner has coordinates ( 1.0, 1.0) and the lower left corner has coordinates ( -1.0, -1.0 ). It has sides that are 2 units long and its center (as well as the center of the inscribed circle) is at the origin.
    A random point inside the dart board can be specified by its x and y coordinates. These values are generated using the random number generator. There is a method nextDouble() that will return a double between 0.0 (inclusive) and 1.0 (exclusive). But we need random numbers between -1.0 and +1.0. The way we achieve that is:
    double xPos = (randomGen.nextDouble()) * 2 - 1.0;
    double yPos = (randomGen.nextDouble()) * 2 - 1.0;
    To determine if a point is inside the circle its distance from the center of the circle must be less than the radius of the circle. The distance of a point with coordinates ( xPos, yPos ) from the center is Math.sqrt ( xPos * xPos + yPos * yPos ). The radius of the circle is 1 unit.
    The class that you will be writing will be called CalculatePI. It will have the following structure:
    import java.util.*;
    public class CalculatePI
    public static boolean isInside ( double xPos, double yPos )
    public static double computePI ( int numThrows )
    public static void main ( String[] args )
    In your method main() you want to experiment and see if the accuracy of PI increases with the number of throws on the dartboard. You will compare your result with the value given by Math.PI. The quantity Difference in the output is your calculated value of PI minus Math.PI. Use the following number of throws to run your experiment - 100, 1000, 10,000, and 100,000. You will call the method computePI() with these numbers as input parameters. Your output will be of the following form:
    Computation of PI using Random Numbers
    Number of throws = 100, Computed PI = ..., Difference = ...
    Number of throws = 1000, Computed PI = ..., Difference = ...
    Number of throws = 10000, Computed PI = ..., Difference = ...
    Number of throws = 100000, Computed PI = ..., Difference = ...
    * Difference = Computed PI - Math.PI
    In the method computePI() you will simulate the throw of a dart by generating random numbers for the x and y coordinates. You will call the method isInside() to determine if the point is inside the circle or not. This you will do as many times as specified by the number of throws. You will keep a count of the number of times a dart landed inside the circle. That figure divided by the total number of throws is the ratio � / 4. The method computePI() will return the computed value of PI.
    and below is what i have so far:
    import java.util.*;
    public class CalculatePI
      public static boolean isInside ( double xPos, double yPos )
         double distance = Math.sqrt( xPos * xPos + yPos * yPos );        
      public static double computePI ( int numThrows )
        Random randomGen = new Random ( System.currentTimeMillis() );
        double xPos = (randomGen.nextDouble()) * 2 - 1.0;
        double yPos = (randomGen.nextDouble()) * 2 - 1.0;
        int hits = 0;
        int darts = 0;
        int i = 0;
        int areaSquare = 4 ;
        while (i <= numThrows)
            if (distance< 1)
                hits = hits + 1;
            if (distance <= areaSquare)
                darts = darts + 1;
            double PI = 4 * ( hits / darts );       
            i = i+1;
      public static void main ( String[] args )
        Scanner sc = new Scanner (System.in);
        System.out.print ("Enter number of throws:");
        int numThrows = sc.nextInt();
        double Difference = PI - Math.PI;
        System.out.println ("Number of throws = " + numThrows + ", Computed PI = " + PI + ", Difference = " + difference );       
    }when I tried to compile it says "cannot find variable 'distance' " in the while loop. but i thought i already declare that variable in the above method. Please give me some ideas to solve this problem and please check my program to see if there is any other mistakes.
    Thanks a lot.

    You've declared a local variable, distance, in the method isInside(). The scope of this variable is limited to the method in which it is declared. There is no declaration for distance in computePI() and that is why the compiler gives you an error.
    I won't check your entire program but I did notice that isInside() is declared to be a boolean method but doesn't return anything, let alone a boolean value. In fact, it doesn't even compute a boolean value.

  • Need help with designing form for exports

    Hi
    I am pretty new to designing form in adobe acrobat.
    I have adobe acrobat 9 standard with Adobe liveCycle Designer installed.
    There are couple of things I want to do.
    1.
    I would like to add a box where I can change the number (default is 1), and when I increase it, (for instance to two)
    then
    it will postulate the particular sections twice.
    For instance, I am taking two drugs right now, then I would like to increase the number of drugs to 2, so then for each drug
    I would enter appropriate information such as drug name, drug form, route of drug administration etcs
    I hope this is clear
    2.
    I am trying to export this in xml format so that only the ones where the user fills in in pdf form gets exported to xml format.
    I would like the boxes to have its own tag, for instance the drug name mentioned above can have a tag of <drugname></drugname>
    I know this is possible through changing the box's name in binding tab.
    What I am interested in is to add a tag for the section, like a header.
    For example, if I were to enter two drug information I want the first drug information to be exported to be
    <drug>
    <drugname>blah</drugname><drugform>1</drugform><drugroute>oral</drugroute>
    </drug>
    <drug>
    <drugname>drug2</drugname><drugform>1</drugform>
    <drugroute>ophthalmic</drugroute>
    </drug>
    how would I add <drug> </drug> for each drug?
    also, can I change the order of the tags??
    in the pdf form, if the drugname box is displayed later than drugroute box, then when I export it, it will display as
    <drugroute>oral</drugroute><drugname>blah</drugname>
    but I want to manually set the order of tags when exported.
    Sorry I asked so many questions
    I hope it is clear enough for you to visualize what I am trying to do
    Thank you so much

    1. You can certainly add sections for the number of drugs that the user specifies pr
    ovided that the form is set up the correct way to begin with. The drug information section must be wrapped in a subform (usually Poistioned) and that in turn must be wrapped in a flowed subform. Then the form must be saved as dynamic. If this information is all that is on the form then that shoudl be all you need to do. If th edrug section is in the middle of the form then you need to wrap the other parts of the form in a subform so they can be pushed down when we add the drug subforms. It can get confusing ...seeing the form amnd its structure would help to clarify.
    2. You canbnot change the names of tags on the fly but you can change their values. AS mentioned above, when you wrap the Drug information in a subform that subform name can be used as a tag in the XML. Then you could have a node with the tag (or an attribute) that names the drug in question. Something like this:
    <Drug Section>
         <Drug>
              <DrugName></DrugName>
              <Dossage></Dossage>
              <Supplier></Supplier>
         </Drug Subform>
         <Drug>
              <DrugName></DrugName>
              <Dossage></Dossage>
              <Supplier></Supplier>
         </Drug>
    </Drug Section>
    As mentioned earlier this is always easier to explain when you see it in context of your form.....if you want to send it to me at [email protected] I can get you started at least. Please include a description of your issue in the email
    Paul

  • Need help with crazy custom calculations code in Acrobat XI pro

    Im trying to calculate some text feilds together and just cant figure it out.  I have two text feild boxes that I would input certain numbers to calculate in, Textfeild D5 and D6,  once the user supplies the numbers in the D5 and D6   I need a text feild (D9) to calculate and produce a number thats used in another calculation. Any help would be greatly appriciated. Im good at HTML and CSS but only begining with javascript. Im using acrobat XI pro and I put this code in the custom javascript area within the text feld "D9" properties.
    var Dsix = +getField("D6").value;
    var Dfive = +getFeild("D5").value;
    var B2 = 0.37;
    var B3 = 0.45;
    var B4 = 0.53;
    if (Dsix = 15){
    D9.value = B2*Dfive;
    if (Dsix = 30){
    D9.value = B3*Dfive;
    if (Dsix = 45){
    D9.value = B4*Dfive;

    Well thats makes since but unfortunitly it didnt work. The green text feild D9 is where im placing code at. they will be hiiden feilds. the red outlined text feilds are all input feilds. seconds is D6 and nozzels is D5.

  • Portfolio site, need help with contact form

    Hi,
    Im a graphic designer turned web designer student. I dont know A LOT of flash, but im learning more as time goes by in and out of school. I currently redid my portfolio website, before it was more of a design taken into dreamweaver and uploaded. Now everything is not completely done, but im doing the site in flash.
    www.Nikdesigns.com, if anyones interested...
    but im trying to set up a really basic contact page. I have a name/email and message input text boxes and a submit button so far. Is there anyway someone can explain to me exactly what code I need, and what I need to do to be able to set this up correctly? Or link me a good tutorial?
    I understand flash needs a php to send the info out and comunicate with, but other then that im lost. What actionscript? and what keyframe?
    flash is so frustrating =/ someone please help, lol.

    If your contact page is just 1 of the many pages in your site, I'll recommend you write it in HTML/PHP/JSP.
    There are many cases when Flash/AS is the efficient tool to get jobs done. But just my humble opinion, I think in this case you'll be more efficient to construct the contacts page with mark-up languages.
    Of course, it is possible to do it in Flash/AS and not difficult. I just have 1 question before I go off and try:
    When an user submits the form, how do you wish to receive it? As an email in your inbox? Store it in a database? Or elsewhere?
    Cheers,

  • Need help with PHP form processor coding

    I posted my first question on this forum earlier today and got help quickly. I'm going to try again and see who can help me this time.
    I have a customer feedback form that I designed and I am using Spry validation on the fields and I'm use Recaptcha as well. Now I'm trying to get the form handler working. I know there are some canned procedures out there but I hate using too much code that I don't understand at all.  I'm sure my first attempt at PHP coding is horrible but we all have to learn. My processor is working in some areas but there are holes I don't know how to fill in:
    1. When I validate the Recaptcha input, if it was entered correctly, I go on to send an email to the appropriate person BUT how do I send them a message and get back to the form if the recaptcha validation fails and still have their entries in place?
    2. Assuming the recaptcha validated correctly, my procedure sends an email  and it writes the comments to a file for historical purposes. These parts seem to be working (by some miracle). Once I do this, I think I would like to open a little window to send the customer a confirmation message, have them click the box to confirm and close the window and then take them back to the feedback form but now have it be reset. I'm not sure how to do these steps.
    Does anyone have a SIMPLE example to accomplish these steps?
    Thanks much!!
    Donna

    It would be hard to give you substantive examples of how to accomplish your goals here without seeing your PHP code, but in general the following methods would work:
    1.  To return to the form with the fields populated, is easiest when the processing script and the form code are on the same page.  The idea is that when the form is not properly completed, you fall back into the form code and use the data from the posted values to repopulate the fields, e.g.,
    <input type="text' name="whatever" value="<?php isset($_POST['whatever']) { echo $_POST['whatever']; ?>">
    or
    <select name="whatever2">
    <option<?php if(isset($_POST['whatever2']) && $_POST['whatever2']=='this_option_value') { echo ' selected="selected"'; } ?>>this_option_value</option>
    </select>
    Each field is set to repeat the posted data (if the corresponding $_POST value is set - to avoid error messages when the page is first loaded).
    2.  You can place the confirmation message on the page with CSS that hides it.  When the form is submitted successfully, just set a variable that is used to show the previously hidden message, e.g.,
    Assume the following CSS -
    #message { display:none; }
    and the following HTML -
    <p id="message">Congratulations</p>
    and the fact that you have set a PHP variable called $success to be true when the form is successfully submitted, you would just modify the HTML like this -
    <p id="message"<?php if($success) { echo ' style="display:block"; } ?>>Congratulations</p>
    Make sense?

  • Need Help With DW Form

    I’m new to coding calculations in forms. Any
    suggestions greatly appreciated. This is just a generic test form I
    designed in DW. I’m trying to figure out how to add the
    dollar value of radio group “sessionoption" to the dollar
    value of radio group sessionoption.”
    Somehow I have to post the sum of these two values into tag:
    <INPUT type="hidden" name="chargetotal" value=" ">
    This is for a simple order form that will eventually go to a
    gateway. I’m just trying to get the easiest method for
    creating this calculation (maybe a javascript). Even a reference to
    a tutorial would be helpful. Here is the code:
    <body>
    <form id="form1" name="form1">
    <p>
    <INPUT type="hidden" name="chargetotal" value=" ">
    <INPUT type="hidden" name="storename" value="000000">
    <input type="hidden" name="taxexempt" value="1">
    <input type="hidden" name="txntype" value="preauth">
    <input type="hidden" name="authenticateTransaction"
    value="true">
    <input type="hidden" name="responseURL" value="
    http://www.mystore.com/receipt.cgi">
    <input type="hidden" name="oid" value="webform1">
    <br />
    <br />
    <br />
    </p>
    <FORM
    action="https://www.mygatewaytest.com/lpc/servlet/lppay"
    method="post">
    <table width="100%" border="0">
    <tr>
    <td>
    Please Choose On Of The Following Consultation
    Amounts:<br />
    <br />
    <table width="314">
    <tr>
    <td width="306"><label>
    <input type="radio" name="sessionoption" value="20.00"
    id="sessionoption_0" />
    45 Minutes ($20.00)</label></td>
    </tr>
    <tr>
    <td><label>
    <input type="radio" name="sessionoption" value="15.00"
    id="sessionoption_1" />
    35 Minutes ($15.00)</label></td>
    </tr>
    <tr>
    <td><label>
    <input type="radio" name="sessionoption" value="10.00"
    id="sessionoption_2" />
    25 Minutes ($10.00)</label></td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    <table width="100%" border="0">
    <tr>
    <td><br />
    Please choose one of the options for a recording of your
    consultation:<br />
    <table width="200">
    <tr>
    <td><label>
    <input type="radio" name="audiooption" value="5.00"
    id="audiooption_0" />
    postal mail ($5.00)</label></td>
    </tr>
    <tr>
    <td><label>
    <input type="radio" name="audiooption" value="3.00"
    id="audiooption_1" />
    email ($3.00)</label></td>
    </tr>
    <tr>
    <td><label>
    <input type="radio" name="audiooption" value="00.00"
    id="audiooption_2" />
    none</label></td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    <br />
    <label>
    <INPUT type="submit" value="Continue to secure payment
    form">
    <br />
    <br />
    </Form>
    <br />
    <br />
    <br />
    <br />
    </body>

    I thought this online version of the form might help:
    http://www.lifeleap.org/CL5/oforms/test2.shtml

  • BPEL Need help with Task Form's bindings' Claim

    Hi,
    I have a customer requirement, they want something like, if there is only one member in a group, when he views the task form from webcenter or from the worklist, the task should be automatically claimed, so he doesn't have to claim the task, and then ongo with what the task-form offers.
    I have seen that Claim method comes from the bindings to the taskDetails.jspx, the code is below which auto-claims the task:
    DCBindingContainer binding = (DCBindingContainer)getBindings();
    DCIteratorBinding iter = binding.findIteratorBinding("taskIterator");
    OperationBinding bind = bindings.getOperationBinding("Claim");
    bind.execute();
    However, there are two problems with this approach.
    1) The Task Form isn't getting updated with the buttons that comes after claiming the task(yes-no-approve-reject-whatever).
    2) If the task is allready claimed, there is an exception.
    The second one, I can manage to overcome somehow, but the first one, I am asking you damn it :)
    Any help would be most appreciated!

    Can someone please help?

  • Help with PDF Form Calculation

    OK So I don't know if this is even possible but what I am wanting is for clients to enter their income in the "income" felid and then for the "contribution" felid to pre-populate with how much they can have contributed...
    if the value is less than $31,920 then it is equal to $1000 – which works
    if the value is more than $61,920 then it is equal to $0 – which also works
    if the value is between $31,920 and $61,920 to apply the following formula:
    1000-(0.0333*(income-31920))  - this is where I am stumped!
    I have used the following code which works for the lesser than / greater than queries... however when I ask it to actually take the value in the box and use it to make a calculation I have no idea where to begin (or even if it is possible) so (as you can probably tell) I have just made up some sort of code which clearly doesn’t work...
    if (this.getField("income").value<31920) {
      event.value = 1000
      } else {
        if (this.getField("income").value>61920) {
        event.value = 0
      } else {
          event.value = 1000-(0.03333*((this.getFeild("income"))-31920))
    Any takers?

    You were very close. Try something like the following as the calculated field's custom Calculate script:
    (function () {
        // Get the field value
        var v = getField("income").value;
        if (v < 31920) {
            event.value = 1000;
            return;
        if (v > 61920) {
            event.value = 0;
            return;
        // v is >= 31920 and =< 61920
        event.value = 1000 - (0.03333 * (v - 31920));

  • Need Help with Conatct Form

    I created a Contact Form  in DW CS6, and I used the php and html files provided by Nancy O. in her forum dated back to October 2011. Follow the link for details. http://forums.adobe.com/message/3970070#3970070
    I believe I have followed all the required steps, and almost everything seems working properly, except that I am not (Recipient) getting an e-mail. However, the client has received an automated reply from me (Recipient). But no e-mail were sent to me.
    Please refer to below (Part of php code - Between Lines 12 and 35) where I have made the changes:
    I am not sure where I have made an error(s). Could anyone please assist?

    Hi Nancy,
    I created a new Gmail address as you suggested, and then tested the Form with it. I still can't receive an e-mail.
    Also, I have contacted my Web Host, and they confirmed that there are no issues from their end.
    I have attached below both the php and the html files, and I would appreciate if you can take a look at them for correctness:
    PHP File:
    <?php
    // Form Processing Script
    // General Variables
        $check_referrer="no";
        $referring_domains="http://domain.com/,http://www.domain.com/,http://subdomain.domain.com/";
    // options to use if hidden field "config" has a value of 0
    // recipient info
        $charset[0]="iso-8859-1";
        $tomail[0]="[email protected]";
        $cc_tomail[0]=" ";
        $bcc_tomail[0]="";
    // Mail contents config
        $subject[0]="message from EMCG.COM";
        $reply_to_field[0]="email";
        $reply_to_name[0]="email";
        $required_fields[0]="first_name,last_name";
        $required_email_fields[0]="email";
        $attachment_fields[0]="";
        $return_ip[0]="yes";
        $mail_intro[0]="The following message was sent from EMCG.COM:";
        $mail_fields[0]="first_name,last_name,email,phone,subject,message";
        $mail_type[0]="text";
        $mail_priority[0]="1";
        $allow_html[0]="no";
    // Send back to sender config
        $send_copy[0]="yes";
        $copy_format[0]="vert_table";
        $copy_fields[0]="first_name,last_name,subject,message";
        $copy_attachment_fields[0]="";
        $copy_subject[0]="EMCG automated reply";
        $copy_intro[0]="Thanks for taking time to contact EMCG. Someone will be in touch with you soon.";
        $copy_from[0]="[email protected]";
        $copy_tomail_field[0]="email";
    // Result options
        $header[0]="";
        $footer[0]="";
        $error_page[0]="";
        $thanks_page[0]="";
    // Default Error and Success Page Variables
        $error_page_title[0]="Error - Missing Fields";
        $error_page_text[0]="Required information is missing. Please use your browser's back button to return to the form and complete the required fields.";
        $thanks_page_title[0]="Success - Form processing completed";
        $thanks_page_text[0]="Thank you. Please check your e-mail for an automated confirmation. ";
    // Antispam Options
        $empty_field[0]="nospam";
        $character_scan[0]="message";
        $time_delay[0]="";
        $captcha_codes[0]="9C2449,EEADC8,77A585,D72838";
        $max_urls[0]="1";
        $max_url_fields[0]="message";
        $flag_spam[0]="";
    // Don't muck around past this line unless you know what you are doing //
    ob_start();
    $config=$_POST["config"];
    $debug=0;
    $debug_text="";
    // fix for Windows email server security
    ini_set("sendmail_from",$tomail[$config]);
    // email validation regular expression
    $regex = "^[-a-z0-9!#$%&\'*+/=?^_`{|}~]+(\.[-a-z0-9!#$%&\'*+/=?^_`{|}~]+)*@(([a-z0-9]([-a-z0-9]*[a -z0-9]+)?){1,63}\.)+([a-z]([-a-z0-9]*[a-z0-9]+)?){2,63}$";
    $header_injection_regex = "(\r|\n)";
    if($header[$config]!="")
        include($header[$config]);
    if($_POST["submit"] || $_POST["Submit"] || $_POST["submit_x"] || $_POST["Submit_x"])
    // begin global functions //
    // get visitor IP
        function getIP()
            if(getenv(HTTP_X_FORWARDED_FOR))
                $user_ip=getenv("HTTP_X_FORWARDED_FOR");
            else
                $user_ip=getenv("REMOTE_ADDR");
            return $user_ip;
    // get value of given key
        function parseArray($key)
            $array_value=$_POST[$key];
            $count=1;
            extract($array_value);
            foreach($array_value as $part_value)
                if($count > 1){$value.=", ";}
                $value.=$part_value;
                $count=$count+1;
            return $value;
    // stripslashes and autolink url's
        function parseValue($value)
            $value=preg_replace("/(http:\/\/+.[^\s]+)/i",'<a href="\\1">\\1</a>', $value);
            return $value;
    // html header if used
        function htmlHeader()
            $htmlHeader="<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n<html>\n<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=".$charset[$config]."\"></head>\n<body>\n<table cellpadding=\"2\" cellspacing=\"0\" border=\"0\" width=\"600\">\n";
            return $htmlHeader;
    // html footer if used
        function htmlFooter()
            $htmlFooter="</table>\n</body>\n</html>\n";
            return $htmlFooter;
    // build verticle table format
        function buildVertTable($fields, $intro, $to, $send_ip)
            $message=htmlHeader();
            if($intro != "")
                $message.="<tr>\n<td align=\"left\" valign=\"top\" colspan=\"2\">".$intro."</td>\n</tr>\n";
            $fields_check=preg_split('/,/',$fields);
            $run=sizeof($fields_check);
            for($i=0;$i<$run;$i++)
                $cur_key=$fields_check[$i];
                $cur_value=$_POST[$cur_key];
                if(is_array($cur_value))
                    $cur_value=parseArray($cur_key);
                $cur_value=parseValue($cur_value);
                if($allow_html[$config]=="no")
                    $cur_value=htmlspecialchars(nl2br($cur_value));
                else
                    $cur_value=nl2br($cur_value);
                $message.="<tr>\n<td align=\"left\" valign=\"top\" style=\"white-space:nowrap;\"><b>".$cur_key."</b></td>\n<td align=\"left\" valign=\"top\" width=\"100%\">".$cur_value."</td>\n</tr>\n";
            if($send_ip=="yes" && $to=="recipient")
                $user_ip=getIP();
                $message.="<tr>\n<td align=\"left\" valign=\"top\" style=\"white-space:nowrap;\"><b>Sender IP</b></td>\n<td align=\"left\" valign=\"top\" width=\"100%\">".$user_ip."</td>\n</tr>\n";
            $message.=htmlFooter();
            return $message;
    // build horizontal table format
        function buildHorzTable($fields, $intro, $to, $send_ip)
            $message=htmlHeader();
            $fields_check=preg_split('/,/',$fields);
            $run=sizeof($fields_check);
            if($intro != "")
                $message.="<tr>\n<td align=\"left\" valign=\"top\" colspan=\"".$run."\">".$intro."</td>\n</tr>\n";
            $message.="<tr>\n";
            for($i=0;$i<$run;$i++)
                $cur_key=$fields_check[$i];
                $message.="<td align=\"left\" valign=\"top\" style=\"white-space:nowrap;\"><b>".$cur_key."</b></td>\n";
            if($send_ip=="yes" && $to=="recipient")
                $message.="<td align=\"left\" valign=\"top\" style=\"white-space:nowrap;\"><b>Sender IP</b></td>\n";
            $message.="</tr>\n";
            $message.="<tr>\n";
            for($i=0;$i<$run;$i++)
                $cur_key=$fields_check[$i];
                $cur_value=$_POST[$cur_key];
                if(is_array($cur_value))
                    $cur_value=parseArray($cur_key);
                $cur_value=parseValue($cur_value);
                if($allow_html[$config]=="no")
                    $cur_value=htmlspecialchars(nl2br($cur_value));
                else
                    $cur_value=nl2br($cur_value);
                $message.="<td align=\"left\" valign=\"top\">".$cur_value."</td>\n";
            $message.="</tr>\n";
            $message.="<tr>\n";
            if($send_ip=="yes" && $to=="recipient")
                $user_ip=getIP();
                $message.="<td align=\"left\" valign=\"top\">".$user_ip."</td>\n";
            $message.="</tr>\n";
            $message.=htmlFooter();
            return $message;
    // build plain text format
        function buildTextTable($fields, $intro, $to, $send_ip)
            $message="";
            if($intro != "")
                $message.=$intro."\n\n";
            $fields_check=preg_split('/,/',$fields);
            $run=sizeof($fields_check);
            for($i=0;$i<$run;$i++)
                $cur_key=$fields_check[$i];
                $cur_value=$_POST[$cur_key];
                if(is_array($cur_value))
                    $cur_value=parseArray($cur_key);
                $cur_value=parseValue($cur_value);
                if($allow_html[$config]=="no")
                    $cur_value=htmlspecialchars($cur_value);
                else
                    $cur_value=$cur_value;
                $message.="".$cur_key.": ".$cur_value."\n";
            if($send_ip=="yes" && $to=="recipient")
                $user_ip=getIP();
                $message.="Sender IP: ".$user_ip."\n";
            return $message;
    // get the proper build fonction
        function buildTable($format, $fields, $intro, $to, $send_ip)
            if($format=="vert_table")
                $message=buildVertTable($fields, $intro, $to, $send_ip);
            else if($format=="horz_table")
                $message=buildHorzTable($fields, $intro, $to, $send_ip);
            else
                $message=buildTextTable($fields, $intro, $to, $send_ip);
            return $message;
    // referrer checking security option
        function checkReferer()
            if($check_referrer=="yes")
                $ref_check=preg_split('/,/',$referring_domains);
                $ref_run=sizeof($ref_check);
                $referer=$_SERVER['HTTP_REFERER'];
                $domain_chk="no";
                for($i=0;$i<$ref_run;$i++)
                    $cur_domain=$ref_check[$i];
                    if(stristr($referer,$cur_domain)){$domain_chk="yes";}
            else
                $domain_chk="yes";
            return $domain_chk;
    // checking required fields and email fields
        function checkFields($text_fields, $email_fields, $regex)
              $error_message="";
            if($debug==1)
                $error_message.="<li>text_fields: ".$text_fields."<br />email_fields: ".$email_fields."<br />reply_to_field: ".$reply_to_field."<br />reply_to_name: ".reply_to_name."</li>";
            if($text_fields != "")
                $req_check=preg_split('/,/',$text_fields);
                $req_run=sizeof($req_check);
                for($i=0;$i<$req_run;$i++)
                    $cur_field_name=$req_check[$i];
                    $cur_field=$_POST[$cur_field_name];
                    if($cur_field=="")
                        $error_message.="<li>You are missing the <b>".$req_check[$i]."</b> field</li>\n";
            if($email_fields != "")
                $email_check=preg_split('/,/',$email_fields);
                $email_run=sizeof($email_check);
                for($i=0;$i<$email_run;$i++)
                    $cur_email_name=$email_check[$i];
                    $cur_email=$_POST[$cur_email_name];
                    if($cur_email=="" || !eregi($regex, $cur_email))
                        $error_message.="<li>You are missing the <b>".$email_check[$i]."</b> field or it is not a valid email address.</li>\n";
            return $error_message;
    // attachment function
        function getAttachments($attachment_fields, $message, $content_type, $border)
            $att_message="This is a multi-part message in MIME format.\r\n";
            $att_message.="--{$border}\r\n";
            $att_message.=$content_type."\r\n";
            $att_message.="Content-Transfer-Encoding: 7bit\r\n\r\n";
            $att_message.=$message."\r\n\r\n";
            $att_check=preg_split('/,/',$attachment_fields);
            $att_run=sizeof($att_check);
            for($i=0;$i<$att_run;$i++)
                $fileatt=$_FILES[$att_check[$i]]['tmp_name'];
                $fileatt_name=$_FILES[$att_check[$i]]['name'];
                $fileatt_type=$_FILES[$att_check[$i]]['type'];
                if (is_uploaded_file($fileatt))
                    $file=fopen($fileatt,'rb');
                    $data=fread($file,filesize($fileatt));
                    fclose($file);
                    $data=chunk_split(base64_encode($data));
                    $att_message.="--{$border}\n";
                    $att_message.="Content-Type: {$fileatt_type}; name=\"{$fileatt_name}\"\r\n";
                    $att_message.="Content-Disposition: attachment; filename=\"{$fileatt_name}\"\r\n";
                    $att_message.="Content-Transfer-Encoding: base64\r\n\r\n".$data."\r\n\r\n";
            $att_message.="--{$border}--\n";
            return $att_message;
    // function to set content type
        function contentType($charset, $format)
            if($format=="vert_table")
                $content_type="Content-type: text/html; charset=".$charset."\r\n";
            else if($format=="horz_table")
                $content_type="Content-type: text/html; charset=".$charset."\r\n";
            else
                $content_type="Content-type: text/plain; charset=".$charset."\r\n";
            return $content_type;
    // end global functions //
    // begin procedural scripting //
        // anti-spam empty field check
        if($_POST[$empty_field[$config]] != "")
            $empty_message = "<li>This submission failed and was flagged as spam.</li>\n";
        // anti-spam character scan check
        if(strlen($character_scan[$config]) > 0)
            $spam_message="";
            $field_check=preg_split('/,/',$character_scan[$config]);
            $field_run=sizeof($field_check);
            for($i=0;$i<$field_run;$i++)
                $cur_field_name=$field_check[$i];
                $cur_field=$_POST[$cur_field_name];
                if(preg_match("/<(.|\n)+?>/", $cur_field) || preg_match("/\[(.|\n)+?\]/", $cur_field))
                    $spam_message.="<li>This message contains disallowed characters.</li>\n";
        // anti-spam time delay check
        if((strlen($time_delay[$config]) > 0 && strlen($_POST["time"]) > 0) || (strlen($time_delay[$config]) > 0 && (strlen($_POST["time"]) == 0 || !$_POST["time"])))
            if((time() - $_POST["time"]) < $time_delay[$config])
                $time_message = "<li>This has been stopped by the timer, and is likely spam.</li>\n";
        // anti-spam CAPTCHA check
        if(strlen($captcha_codes[$config]) > 0)
            $captcha_check=preg_split('/,/',$captcha_codes[$config]);
            if(strtolower($_POST["captcha_entry"]) != strtolower($captcha_check[$_POST["captcha_code"]]))
                $captcha_message = "<li>CAPTCHA test did not match.</li>\n";
        // anti-spam max URL check
        if(strlen($max_url_fields[$config]) > 0)
            $max_url_message="";
            $field_check=preg_split('/,/',$max_url_fields[$config]);
            $field_run=sizeof($field_check);
            for($i=0;$i<$field_run;$i++)
                $cur_field_name=$field_check[$i];
                $cur_field=$_POST[$cur_field_name];
                preg_match_all("/http:/", $cur_field, $matches);
                if(count($matches[0]) > $max_urls[$config])
                    $max_url_message.="<li>This message contains too many URL's.</li>\n";
        // set anti-spam flagging option
        if(strlen($empty_message.$spam_message.$time_message.$captcha_message.$max_url_message) > 0 && strlen($flag_spam[$config]) == 0)
            $set_flag = 2;
        else if(strlen($empty_message.$spam_message.$time_message.$captcha_message.$max_url_message) > 0 && strlen($flag_spam[$config]) > 0)
            $set_flag = 1;
        else
            $set_flag = 0;
        // header injection check
           $security_filter="";
        if(strlen($_POST[$reply_to_field[$config]]) > 0)
            if(eregi($header_injection_regex,$_POST[$reply_to_field[$config]]))
                $security_filter.="<li>Header injection attempt detected, mail aborted.</li>\n";
            else
                $reply_to_field_checked=$_POST[$reply_to_field[$config]];
        if(strlen($_POST[$reply_to_name[$config]]) > 0)
            if(eregi($header_injection_regex,$_POST[$reply_to_name[$config]]))
                $security_filter.="<li>Header injection attempt detected, mail aborted.</li>\n";
            else
                $reply_to_name_checked=$_POST[$reply_to_name[$config]];
        // check domain referrer and continue
        $domain_chk=checkReferer();
        if($domain_chk=="yes")
            $error_message=checkFields($required_fields[$config], $required_email_fields[$config], $regex);
            if(strlen($error_message) < 1 && strlen($security_filter) < 1 && $set_flag < 2)
                // build appropriate message format for recipient
                $content_type=contentType($charset[$config], $mail_type[$config]);
                $message=buildTable($mail_type[$config], $mail_fields[$config], $mail_intro[$config], "recipient", $return_ip[$config]);
                // build header data for recipient message
                //$extra="From: ".$_POST[$reply_to_field[$config]]."\r\n";
                $extra="From: ".$reply_to_name_checked." <".$reply_to_field_checked.">\r\n";
                if($cc_tomail[$config]!="")
                    $extra.="Cc: ".$cc_tomail[$config]."\r\n";
                if($bcc_tomail[$config]!="")
                    $extra.="Bcc: ".$bcc_tomail[$config]."\r\n";
                if($mail_priority[$config]!="")
                    $extra.="X-Priority: ".$mail_priority[$config]."\r\n";
                // get attachments if necessary
                if($attachment_fields[$config]!="")
                    $semi_rand=md5(time());
                    $border="==Multipart_Boundary_x{$semi_rand}x";
                    $extra.="MIME-Version: 1.0\r\n";
                    $extra.="Content-Type: multipart/mixed; boundary=\"{$border}\"";
                    $message=getAttachments($attachment_fields[$config], $message, $content_type, $border);
                else
                    $extra.="MIME-Version: 1.0\r\n".$content_type;
                // send recipient email
                if($debug==1)
                    if($set_flag == 1)
                        $debug_text.="<p><b>Mail would have sent flagged for spam if not in debug mode.</b></p>";
                    else
                        $debug_text.="<p><b>Mail would have sent if not in debug mode.</b></p>";
                else if($debug==0)
                    if($set_flag == 1)
                        $subject = $flag_spam[$config]." ".$subject[$config];
                    else
                        $subject = $subject[$config];
                    mail("".$tomail[$config]."", "".stripslashes($subject)."", "".stripslashes($message)."", "".$extra."");
                // autoresponse email if necessary
                if($send_copy[$config]=="yes")
                    // build appropriate message format for autoresponse
                    $content_type=contentType($charset[$config], $copy_format[$config]);
                    $message=buildTable($copy_format[$config], $copy_fields[$config], $copy_intro[$config], "autoresponder", $return_ip[$config]);
                    // build header data for autoresponse
                    $copy_tomail=$_POST[$copy_tomail_field[$config]];
                    $copy_extra="From: ".$copy_from[$config]."\r\n";
                    // get autoresponse  attachments if necessary
                    if($copy_attachment_fields[$config]!="")
                        $semi_rand=md5(time());
                        $border="==Multipart_Boundary_x{$semi_rand}x";
                        $copy_extra.="MIME-Version: 1.0\r\n";
                        $copy_extra.="Content-Type: multipart/mixed; boundary=\"{$border}\"";
                        $message=getAttachments($copy_attachment_fields[$config], $message, $content_type, $border);
                    else
                        $copy_extra.="MIME-Version: 1.0\r\n".$content_type;
                    // send autoresponse email
                    if($debug==1)
                        if($set_flag == 1)
                            $debug_text.="<p><b>Autoresponder would have sent flagged for spam if not in debug mode.</b></p>";
                        else
                            $debug_text.="<p><b>Autoresponder would have sent if not in debug mode.</b></p>";
                    else if($debug==0)
                        $send_copy = 1;
                        if($copy_tomail=="" || !eregi($regex,$copy_tomail))
                            $send_copy = 0;
                        if($send_copy == 1)
                            if($set_flag == 1)
                                $copy_subject = $flag_spam[$config]." ".$copy_subject[$config];
                            else
                                $copy_subject = $copy_subject[$config];
                            mail("$copy_tomail", "".$copy_subject."", "$message", "$copy_extra");
                // showing thanks pages from a successful submission
                if($thanks_page[$config]=="")
                    echo "<h3>".$thanks_page_title[$config]."</h3>\n";
                    echo "<p>".$thanks_page_text[$config]."</p>\n";
                    if(strlen($debug_text) > 0)
                        echo "<p><b><i>".$debug_text."</i></b></p>\n";
                else
                    header("Location: ".$thanks_page[$config]);
            else
                // entering error page options from missing required fields
                if($error_page[$config]=="")
                    echo "<h3>".$error_page_title[$config]."</h3>\n";
                    echo "<ul>\n";
                    echo $security_filter.$empty_message.$error_message.$spam_message.$time_message.$captcha_messa ge.$max_url_message;
                    echo "</ul>\n";
                    echo "<p>".$error_page_text[$config]."</p>\n";
                else
                    header("Location: ".$error_page[$config]);
        else
            echo "<h3>".$error_page_title[$config]."</h3>\n";
            // message if unauthorized domain trigger from referer checking option
            echo "<p>Sorry, mailing request came from an unauthorized domain.</p>\n";
    // end procedural scripting //
    else
        echo "<h3>Error</h3>";
        echo "<p>No form data has been sent to the script</p>\n";
    if($footer[$config]!="")
        include($footer[$config]);
    ob_end_flush();
    ?>
    <input type="button" value="Return to Form" onClick="javascript: history.go(-1);" />
    HTML File:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Sample Form</title>
    <style type="text/css">
    /**BEGIN FORM STYLES**/
    #form1 {
    font-size: 14px;
    width: 500px;
    margin: 0 auto; /**centered**/
    background: #FFF;
    border: 2px groove green;
    padding: 7px 14px 7px 14px;
    fieldset {
    margin-bottom: 5px;
    border-right: none;
    border-bottom: none;
    border-left: none;
    legend {
    padding: 8px;
    border: 1px solid silver;
    background: #009900;
    font-weight: bold;
    color: #FFFFFF;
    margin-left: -75px;
    *margin-left:0;
    line-height: 1.5
    /**wrap form lables and fields inside ordered lists for better web accessibility**/
    #form1 ol {
    list-style: none;
    margin: 0;
    padding: 0
    #form1 li {
    padding: 5px;
    margin: 0;
    clear: left;
    label {
    display: inline-block;
    float: left;
    line-height: 23px; /**lines up labels with fields**/
    width: 167px;
    font-size: 12px;
    color: #666;
    text-align: right;
    margin-right: 10px; /*space between labels, fields*/
    input[type=text], textarea {
    width: 190px; /**same width on text fields**/
    padding: 5px;
    color: #666;
    border: 1px dotted #009900;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    /**field background on focus**/
    input:focus, input:active, textarea:focus, textarea:active {
    background-color: #EBECDE;
    border: 1px solid;
    #submit {
    margin-left: 45px;
    background: #009900;
    font-size: 18px;
    color: #FFF;
    font-weight: bold;
    border: 2px outset #FFF
    #submit:hover, #submit:focus, #submit:active {
    background: #006600;
    color: yellow;
    border: 2px inset #FFF
    /**END FORM STYLES**/
    </style>
    </head>
    <body>
    <!--BEGIN HTML FORM, action="path to form-processing script on your server" -->
    <form id="form1" action="vsi2.php" method="post" enctype="multipart/form-data" name="form1">
      <h3>HTML Contact Form</h3>
      <fieldset>
        <legend>Required Fields:</legend>
        <!--spam prevention-->
        <input name="config" type="hidden" value="0" />
        <input type="text" name="nospam" style="display:none" />
        <ol>
          <li>
            <label for="first_name">First Name:</label>
            <input name="first_name" id="first_name" type="text" />
          </li>
          <li>
            <label for="last_name">Last Name:</label>
            <input name="last_name" id="last_name" type="text" />
          </li>
          <li>
            <label for="email">E-mail:</label>
            <input name="email" id="email" type="text" />
          </li>
        </ol>
      </fieldset>
      <fieldset>
        <legend>Optional Fields:</legend>
        <ol>
          <li>
            <label for="phone">Phone number:</label>
            <input name="phone" id="phone" type="text" />
          </li>
          <li>
            <label for="subject">Subject:</label>
            <input name="subject" id="subject" type="text" />
          </li>
          <li>
            <label for="message">Message:</label>
            <textarea id="message" name="message"></textarea>
          </li>
          <li>
            <label for="submit"> </label>
            <input type="submit" name="submit" id="submit" value="Submit" />
          </li>
        </ol>
      </fieldset>
    </form>
    <!--END OF FORM -->
    </body>
    </html>
    Test File:
    http://www.energymcg.com/Original/contactus.html
    Thank you for your patience and for sticking with me. I really appreciate it.
    Khalid

  • Need help with a form where checkbox displays another field

    I created a from in january that works perfectly.  I have different departments as checkboxes and if the box is checked, it displays another subform with a comments, approval, and signature field.  However, we just added two new departments.  I copied one of the checkboxes and subsequent fields twice.  I then changed the script for the approriate field and checked to make sure there were no other functions I was missing.  However, now when I open the form, the two new fields show by default.  If I check the box and uncheck, the associated subform disappears.  I think there may be some simple thing i am overlooking. 

    I'm not getting any errors at all. The form isn't online as of yet so I dont have a link. I will attach a screen shot and maybe you can tell me where I went wrong.

  • Need help with Report Script calculation...

    When trying to implement a calculation on 2 members (sales, tax exempt) I am having a problem keeping the report from accumulating the calculation total...
    Any ideas would certainly be appreciated.
    Thanks,
    //*****Script******
    { CALCULATE ROW  "item1" OFF}     //sets variable for first calculation item
    { CALCULATE ROW  "item2" OFF}     //sets variable for second calculation item
    <row("entities", "Measures")
    //{Supoutput}
    {SETROWOP "item1" +}     //starts adding the member
    "Sales"
    {SETROWOP "item1" OFF}     //stops adding the member
    {SETROWOP "item2" +}          //starts adding the member
    "tax exempt"
    {SETROWOP "item2" OFF}     //stops adding the member
    //{OUTPUT}
    { CALCULATE ROW  "total sales" = "item1" - "item2"
    PRINTROW "total sales"}
    //*****what I am expecting******
    north      sales     777.00
    north      tax exempt     27.00
    north      total sales     750.00
    south      sales     796.00
    south      tax exempt     23.00
    south      total sales     773.00     <======     correct
    //******actualreport results******
    north     sales     777.00
    north      tax exempt     27.00
    north      total sales     750.00
    south     sales     796.00
    south      tax exempt     23.00
    south      total sales     1523.00     <==== accumulated number / wrong!
    Edited by: Adam M on Sep 29, 2011 5:06 PM

    You should do this calculation in Essbase, not in report script. Add dynamic calc member "Total Sales" with formula "Sales" - "Tax Exempt"...
    Regards,
    Yuri

Maybe you are looking for