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
Drop down list populates other text boxes
Collapse
This topic is closed.
X
X
-
Drop down list populates other text boxes
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. ThanksComment
-
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:
Code:// the data storage part var phones = { city_1 : { fire: 112, police: 110, rescue: 113 }, city_2 : { // see above } } // the view part function setPhones() { document.getElementById("fire").value = phones[this.value].fire; // similar for police and rescue } // the event part document.getElementById("dropdown").addEventListener("change", setPhones);
Comment
-
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...
Code:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> New Document </TITLE> <META NAME="Generator" CONTENT="EditPlus"> <META NAME="Author" CONTENT=""> <META NAME="Keywords" CONTENT=""> <META NAME="Description" CONTENT=""> <script type="text/javascript"> function doThis() { var sel = document.getElementById('conSelect').options[document.getElementById('conSelect').selectedIndex].value; //alert(sel); if(sel=="UK") { document.getElementById('text1').value="111"; document.getElementById('text2').value="111"; document.getElementById('text3').value="111"; } else { document.getElementById('text1').value="222"; document.getElementById('text2').value="222"; document.getElementById('text3').value="222"; } } </script> </HEAD> <BODY> <select onchange="doThis()" id="conSelect"> <option value="US">US</option> <option value="UK">UK</option> </select> <br/> <input type="text" id="text1" /> <input type="text" id="text2" /> <input type="text" id="text3" /> </BODY> </HTML>
Comment
-
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?Comment
-
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.Comment
-
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").val ue == "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.Comment
Comment