...

View Full Version : help needed for simple code in Adobe forms



nophster
04-03-2009, 11:34 PM
Hi...

I am not sure if this is the correct forum, so please bear with me.

I am trying to design a Purchase Order form in Adobe Life Cycle 8. What I basically want is a drop-down box with around 8 fixed options, and the user selects one. As a result of that selection, another text box gets populated with a pre-determined text string. In this case, the drop-box contains a list of products, and when a client selects a product, its product code should automatically appear in another text box. This is to minimize the chance of error on the client's part in entering the product code.

Now I can't figure out how to "get" the value (assigned or actual) of the item selected in the drop-box and how exactly to relate the drop-box and the text box.

Can someone help?

TinyScript
04-04-2009, 12:18 AM
Someone else posted this earlier this week here. I liked it so I saved a copy. You should be able to adapt this to your needs.


<html>
<head>
<title>DD Calculations</title>
<script type="text/javascript">
function getSBox(IDS) {
var obj = document.getElementById(IDS);
return obj.value;
}
function calc() {
var sum = 0;
var temp = '';
temp = getSBox('Machine');
var Machine = Number(temp);
if (isNaN(Machine) || (Machine == 0)) { sum = 0; } else { sum = Machine; }
temp = getSBox('Term');
var Term = Number(temp);
if (isNaN(Term) || (Term == 0)) { sum = 0; } else { sum += Term; }
if (sum == 0) {
temp = 0;
} else {
temp = Machine / Term * 3;
}
document.getElementById('deposit').value = temp.toFixed(2);
return;
}
</script>
</head>
<body>
<select id="Machine" name="machine" onchange="calc()">
<option value="">Choose machine</option>
<option value="4000">2005 - Almida XAS47 (660 Hours) 4000</option>
<option value="5000">Something else 5000</option>

<option value="6000">Something completely different 6000</option>
</select>
<select id="Term" name="term" onchange="calc()">
<option value="">Choose term</option>
<option value="12">1 years</option>
<option value="18">1.5 years</option>
<option value="24">2 years (&pound;46.85)</option>

<option value="60">5 years</option>
</select>
<input id="deposit" name="deposit" readonly/>
</body>
</html>

Alex Vincent
04-04-2009, 02:18 AM
How is this a XML question? Do you have source code for us to work with?

kitchen87
04-04-2009, 07:54 AM
Someone else posted this earlier this week here. I liked it so I saved a copy. You should be able to adapt this to your needs.


<html>
<head>
<title>DD Calculations</title>
<script type="text/javascript">
function getSBox(IDS) {
var obj = document.getElementById(IDS);
return obj.value;
}
function calc() {
var sum = 0;
var temp = '';
temp = getSBox('Machine');
var Machine = Number(temp);
if (isNaN(Machine) || (Machine == 0)) { sum = 0; } else { sum = Machine; }
temp = getSBox('Term');
var Term = Number(temp);
if (isNaN(Term) || (Term == 0)) { sum = 0; } else { sum += Term; }
if (sum == 0) {
temp = 0;
} else {
temp = Machine / Term * 3;
}
document.getElementById('deposit').value = temp.toFixed(2);
return;
}
</script>
</head>
<body>
<select id="Machine" name="machine" onchange="calc()">
<option value="">Choose machine</option>
<option value="4000">2005 - Almida XAS47 (660 Hours) 4000</option>
<option value="5000">Something else 5000</option>

<option value="6000">Something completely different 6000</option>
</select>
<select id="Term" name="term" onchange="calc()">
<option value="">Choose term</option>
<option value="12">1 years</option>
<option value="18">1.5 years</option>
<option value="24">2 years (&pound;46.85)</option>

<option value="60">5 years</option>
</select>
<input id="deposit" name="deposit" readonly/>
</body>
</html>


thanks for sharing this coding..can this code use in wordpress base?

nophster
04-11-2009, 12:20 PM
How is this a XML question? Do you have source code for us to work with?

Can you suggest an appropriate forum for posting questions related to Adobe forms? The language there is either Java or FormCalc. My question was related to FormCalc and I do not see a forum for that here.

Can someone tell me how to get the value of the current selected option from a drop-down list in FormCalc? If there is a drop-down list called Products1, and the options are Prod1, Prod2 and Prod3.....I would like to declare a variable and assign it a value of '1' if Prod1 is selected, '2' if Prod2 is selected and so on. This way, I want to use the 'if' statement to check which value is selected and to populate another field depending on that selection.

How do I do that?

nophster
04-13-2009, 09:16 AM
Ok I got the solution and here it is, in case anyone is interested. To repeat: this is being used where a drop-down list has various options, and upon the selection of one option another field gets populated with the data corresponding to the selection. In this case, product Car gets selected and the field titled 'UnitPrice' gets populated with the associated price.



(JavaScript, client)

switch (xfa.event.newText)
{
case "Car":
UnitPrice.rawValue = 16.8;
break;

case "Truck":
UnitPrice.rawValue = 9.50;
break;

default:
// unknown item
UnitPrice.rawValue = 0;
break;
}


I would understand if this topic gets moved to the JS board. I was initially looking for a solution in the FormCalc syntax.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum