Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
|
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 5th, 2008, 01:54 PM
Authorized User
 
Join Date: Mar 2007
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help - Javascript Auto fill??

I need some help.

I have a form that if an option or input box is selected, I want the other options/input boxes to go to blank (null). The catch is I don't want to lose the options available in the field, in case someone wants to search on a different field.


Here's a sample form; how does one do this if it's even possible??

Code:
<html>
<body>

<form>

<b>DIRECTOR:</b>
    <select name="f_dir" id="dir" class="select" onChange="changeallDIR(this.value);">
        <option value="" selected></option>
        <option value="John">John</option>
        <option value="Susan">Susan</option>
    </select>
<br>

<b>MANAGER:</b>
    <select name="f_mgr" id="mgr" class="select" onChange="changeMGR(this.value);">
        <option value="" selected></option>
        <option value="Michelle">Michelle</option>
        <option value="Jane">Jane</option>
    </select>
<br>

<b>PHONE:</b>
    <input type="text" name="f_phone" id="phone" class="select" onChange="changePHONE(this.value);">
<br>
</form>

</body>
</html>
Sorry for posting this question (request sample code), but I can't figure out what to do a google search on.

Basically I want the form to reset. So if someone has a director selected, but decide to search on manager I want the form reset if the cursor is moved to manager. Or if someone want to search by the phone number, but already has a manager selected. When the cursor is moved to Phone, I want the form reset.

I hope I made sense.

Thanks!!

 
Old June 12th, 2008, 07:23 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 373
Thanks: 0
Thanked 1 Time in 1 Post
Default

If i understood your question correctly following code will solve your problem
Code:
<html>
<head>
    <script type="text/javascript">
        function resetEl() {
            document.getElementById('formId').reset();
        }
    </script>
</head>
<body>

<form id="formId">

<b>DIRECTOR:</b>
    <select name="f_dir" id="dir" class="select" onChange="changeallDIR(this.value);" onfocus="resetEl();">
        <option value="" selected></option>
        <option value="John">John</option>
        <option value="Susan">Susan</option>
    </select>
<br>

<b>MANAGER:</b>
    <select name="f_mgr" id="mgr" class="select" onChange="changeMGR(this.value);" onfocus="resetEl();">
        <option value="" selected></option>
        <option value="Michelle">Michelle</option>
        <option value="Jane">Jane</option>
    </select>
<br>

<b>PHONE:</b>
    <input type="text" name="f_phone" id="phone" class="select" onChange="changePHONE(this.value);" onfocus="resetEl();">
<br>
</form>

</body>
</html>
Try www.w3schools.com for more examples and info.

- Rakesh





Similar Threads
Thread Thread Starter Forum Replies Last Post
Google Toolbar Auto Fill aliirfan84 ASP.NET 2.0 Professional 0 September 21st, 2007 01:50 AM
How to auto fill a drop down janakiraman ASP.NET 1.0 and 1.1 Basics 1 July 2nd, 2007 06:58 PM
auto fill field mankoti_mankoti2000 Access 1 May 26th, 2006 08:19 AM
auto-fill form crmpicco HTML Code Clinic 2 April 21st, 2005 06:42 AM
Auto-fill acrobat forms with databases ... austinglen Classic ASP Databases 0 January 4th, 2004 08:59 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.