By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,977 Members | 1,589 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,977 IT Pros & Developers. It's quick & easy.

Drop down list populates other text boxes

P: 21
I need help writing a Java Script for Adobe Acrobat Prof 7.0. What I am trying to do is have a list of Cities in a drop down box. When a specific city is selected there are 4 other text boxes that are populated with emergency contact numbers. So to be specific the drop down list is made up of San Angelo and Mertzon. When the user selects San Angelo one text box is filled with the ambulance phone number 325-657-4498 one with the fire department 325-657-3266 one with the air ambulance 325-657-1957 and one with outside rescue 800-277-4354. The numbers would be the only thing that appears in the text boxes and they would be different if Mertzon was selected. I hope this was specific enough because I know NOTHING about Java Script so I need a very specific reply. Thanks
Oct 12 '09 #1

✓ answered by jotr

Thanks for all the help but I finally found what I needed. FYI what I had to do is set up each text box for the ambulance, fire, air ambulance and rescue to look like this (this.getField("City").value == "San Angelo")
event.value = "325-657-4498" Then when the user selects the city from the drop down box all the text boxes automatically fill in.

Share this Question
Share on Google+
7 Replies


Expert 10K+
P: 11,448
A very specific answer: Java isn't Javascript; they're two different languages; try the Javascript forum (look right, near the top of the page).

kind regards,

Jos
Oct 13 '09 #2

P: 21
I need help writing a Java Script for Adobe Acrobat Prof 7.0. What I am trying to do is have a list of Cities in a drop down box. When a specific city is selected there are 4 other text boxes that are populated with emergency contact numbers. So to be specific the drop down list is made up of San Angelo and Mertzon. When the user selects San Angelo one text box is filled with the ambulance phone number 325-657-4498 one with the fire department 325-657-3266 one with the air ambulance 325-657-1957 and one with outside rescue 800-277-4354. The numbers would be the only thing that appears in the text boxes and they would be different if Mertzon was selected. I hope this was specific enough because I know NOTHING about Java Script so I need a very specific reply. Thanks
Oct 13 '09 #3

Dormilich
Expert Mod 5K+
P: 8,639
what is the difference between Javascript for Adobe and Javascript for HTML (well, I only need to know the first one, though)?

if it were like HTML it would work like:
Expand|Select|Wrap|Line Numbers
  1. // the data storage part
  2. var phones = {
  3.     city_1 : { fire: 112, police: 110, rescue: 113 },
  4.     city_2 : { // see above }
  5. }
  6. // the view part
  7. function setPhones()
  8. {
  9.     document.getElementById("fire").value = phones[this.value].fire;
  10.     // similar for police and rescue
  11. }
  12. // the event part
  13. document.getElementById("dropdown").addEventListener("change", setPhones);
Oct 13 '09 #4

RamananKalirajan
100+
P: 607
Hi Jotr,
Dont feel that you know nothing about js.. When we born we dont know anything when we grow we used to explore things and learn them. Js is also liek a kind of thing which can be learnt easily by exploring. Practise Makes Perfection. For your Requirement you can use onchange event in the select box and set the values in the text box easily. But I want to know where you are keeping those phone no's. Wether are you getting those values from any db or you have those phone values in the HTML itself. I am giving a small html code just try it out you can understand the logic behind it...

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <HTML>
  3. <HEAD>
  4. <TITLE> New Document </TITLE>
  5. <META NAME="Generator" CONTENT="EditPlus">
  6. <META NAME="Author" CONTENT="">
  7. <META NAME="Keywords" CONTENT="">
  8. <META NAME="Description" CONTENT="">
  9. <script type="text/javascript">
  10. function doThis()
  11. {
  12.     var sel = document.getElementById('conSelect').options[document.getElementById('conSelect').selectedIndex].value;
  13.     //alert(sel);
  14.     if(sel=="UK")
  15.     {
  16.         document.getElementById('text1').value="111";
  17.         document.getElementById('text2').value="111";
  18.         document.getElementById('text3').value="111";
  19.     }
  20.     else
  21.     {
  22.         document.getElementById('text1').value="222";
  23.         document.getElementById('text2').value="222";
  24.         document.getElementById('text3').value="222";
  25.     }
  26. }
  27. </script>
  28. </HEAD>
  29. <BODY>
  30. <select onchange="doThis()" id="conSelect">
  31. <option value="US">US</option>
  32. <option value="UK">UK</option>
  33. </select>
  34. <br/>
  35. <input type="text" id="text1" />
  36. <input type="text" id="text2" />
  37. <input type="text" id="text3" />
  38. </BODY>
  39. </HTML>
  40.  
Oct 13 '09 #5

Frinavale
Expert Mod 5K+
P: 9,731
I moved the question to the JavaScript forum.
Please make sure to post your question in the appropriate place in the future.

My question is what exactly is "JavaScript for Adobe Acrobat Prof 7.0"???

JavaScript is a scripting language that executes in a web browser. What does this have to do with Adobe Acrobat?
Oct 15 '09 #6

P: 21
Sorry about that I didn't know there was a difference between Java and Javascript. I also did not see the Javascript forum originally. However I had already moved my question after I was told "A very specific answer: Java isn't Javascript"

Apparently the javascript has to be different when using it in Adobe than in a web browser. But don't worry I found another site with the answer.
Oct 15 '09 #7

P: 21
Thanks for all the help but I finally found what I needed. FYI what I had to do is set up each text box for the ambulance, fire, air ambulance and rescue to look like this (this.getField("City").value == "San Angelo")
event.value = "325-657-4498" Then when the user selects the city from the drop down box all the text boxes automatically fill in.
Oct 15 '09 #8

This discussion thread is closed

Replies have been disabled for this discussion.