Solved

Filling out form from drop down menu

Posted on 2006-06-19
3
225 Views
Last Modified: 2008-02-01
Hello.

How can the following be adjusted so that when you click on an option in the top menu, the form at the bottom is automatically filled out?

Thanks for the help!



//////////////////////////////////



<script type="text/javascript" src="http://www.php-development.ru/javascripts/dropdown/dropdown.js"></script>

<div>
<div id="menu_parent"
     style="width: 150px; border: 1px solid black; background: #FFFFEE; padding: 0px 5px;
            color: #008000;">
Select One
</div>
<div id="menu_child" style="position: absolute; visibility: hidden; background: #FFFFEE;">
<a style="display: block; width: 300px; border: 1px solid black; padding: 0px 5px; text-decoration: none; color: #0000C0;" href="#">Title: Page 1 - URL: page1.html</a>
<a style="display: block; width: 300px; border: 1px solid black; padding: 0px 5px; text-decoration: none; color: #0000C0;" href="#">Title: Page 2 - URL: page2.html</a>
<a style="display: block; width: 300px; border: 1px solid black; padding: 0px 5px; text-decoration: none; color: #0000C0;" href="#">Title: Page 3 - URL: page3.html</a>
</div>
<script type="text/javascript">
at_attach("menu_parent", "menu_child", "hover", "y", "pointer");
</script>
</div>

<script type="text/javascript">
at_attach("menu_parent", "menu_child", "hover", "y", "pointer");
</script>

<form action="process.php" method="post">
           Title: <input type="text" name="menu_title" value=""> <br>
           URL: <input type="text" name="menu_url" value=""> <br>
<input type=submit>
</table>
</form>
0
Comment
Question by:hankknight
  • 2
3 Comments
 
LVL 63

Accepted Solution

by:
Zvonko earned 500 total points
ID: 16935026
Like this:

<script type="text/javascript" src="dropdown.js"></script>
<style>
#menu_child a {
  display: block;
  width: 300px;
  border: 1px solid black;
  padding: 0px 5px;
  text-decoration: none;
  color: #0000C0;
}
</style>
<script>
function clickLink(theLink){
  var theForm=document.forms[0];
  theForm.menu_title.value=theLink.innerHTML;
  theForm.menu_url.value=theLink.href;
  return false;
}
</script>
<div>
<div id="menu_parent"
     style="width: 150px; border: 1px solid black; background: #FFFFEE; padding: 0px 5px;
            color: #008000;">
Select One
</div>
<div id="menu_child" style="position: absolute; visibility: hidden; background: #FFFFEE;">
<a href="page1.html" onClick="return clickLink(this)">Page 1</a>
<a href="page2.html" onClick="return clickLink(this)">Page 2</a>
<a href="page3.html" onClick="return clickLink(this)">Page 3</a>
</div>
<script type="text/javascript">
at_attach("menu_parent", "menu_child", "hover", "y", "pointer");
</script>
</div>
<br><br><br><br><br><br><br>

<form action="process.php" method="post">
          Title: <input type="text" name="menu_title" value=""> <br>
          URL: <input type="text" name="menu_url" value=""> <br>
<input type=submit>
</table>
</form>


0
 
LVL 16

Author Comment

by:hankknight
ID: 16935414
Thanks!
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 16935436
You are welcome.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now