?
Solved

Javascript Reset function

Posted on 2005-04-22
6
Medium Priority
?
8,279 Views
Last Modified: 2011-08-18
Cannot get javascript reset function to work in an html pge. It works in a simple test script BUT NOT in my regular page. I would attach the html, but this process does not allow.
0
Comment
Question by:Richard Korts
6 Comments
 
LVL 30

Expert Comment

by:third
ID: 13848675
show us your code.
0
 
LVL 10

Expert Comment

by:avidya
ID: 13849179
hi Rkorts,

you can copy and paste your code in this textbox, please do so or post an url
0
 
LVL 31

Expert Comment

by:GwynforWeb
ID: 13849910
this is how a reset button works in a form ,ie it will set the form field values back to the default values

<form>
 <input type="text" value="hello">
 <input type="text">
 <input type="submit">
 <input type="reset">
</form>

The only thing I can think of is that the reset button is outside the form tags. Without seeing the code it is impossible to see what is wrong, I am sure you understand this.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 15

Expert Comment

by:VincentPuglia
ID: 13850021
While you are at it, check the source on the web and make sure it contains only what you intended.  Many 'helpful' programs (Norton's firewall, for example) add code that prevent other code from executing properly.
0
 

Author Comment

by:Richard Korts
ID: 13850234
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
      <title>A J Antico Irrigation Systems</title>
      
<style type="text/css">
      .pt11 {font-size: 11pt; font-family: Arial}
      .pt10 {font-size: 10pt; font-family: Arial}
      .pt8  {font-size: 8pt; font-family: Arial}
      .pt9  {font-size: 9pt; font-family: Arial}      
      .pt7  {font-size: 7pt; font-family: Arial}
      UL.GREEN {
      list-style-type: disc;
      color: green;
}

</style>      
<script language="JavaScript">
<!--
      browver = parseInt(navigator.appVersion);      

      
      function do_reset() {
            alert("first name = " + document.sr_form.fname.value);

            document.sr_form.reset();
            return true;
      }      
      
// -->
</script>                  
</head>

<body topmargin="0" leftmargin="0">
<map name="homecircle">
      <area shape="circle" coords="91,15,14" href="intro.htm">
</map>      
<script language="JavaScript1.2">dqm__codebase = "" //script folder location</script>
<script language="JavaScript1.2" src="sample_settings.js"></script>
<script language="JavaScript1.2" src="dqm_loader.js"></script>
      <table border="0" cellpadding="0" cellspacing="0" width="760">
            <tr>
                  <td colspan="5"><img src="images/top_head_760.jpg"><br>
                  <img src="images/home_head_760.jpg" ISMAP USEMAP="#homecircle" border="0"><img src="images/text_head_sr.jpg"></td>
            </tr>
            <tr>
                  <td colspan="5"><img src="images/spacer.gif" width="30" height="20"></td>
            </tr>
            <tr>
                  <td align="left" valign="top">
                        <img src="images/spacer.gif" width="10" height="5"><br>
                        <a href="intro.htm"><img src="images/b_intro.jpg" border="0"></a><br>
                        <img src="images/spacer.gif" width="10" height="3"><br>                        
                        <img src="images/b_about.jpg" name="menu0" id="menu0" onmouseover="showMenu(event)" onmouseout="hideMenu(event)"><br>
                        <img src="images/spacer.gif" width="10" height="3"><br>                        
                        <img src="images/b_svcs.jpg" name="menu1" id="menu1" onmouseover="showMenu(event)" onmouseout="hideMenu(event)"><br>
                        <img src="images/spacer.gif" width="10" height="3"><br>                        
                        <img src="images/b_prods.jpg" name="menu2" id="menu2" onmouseover="showMenu(event)" onmouseout="hideMenu(event)"><br>
                        <img src="images/spacer.gif" width="10" height="3"><br>                        
                        <img src="images/b_nletter.jpg" name="menu3" id="menu3" onmouseover="showMenu(event)" onmouseout="hideMenu(event)"><br>      
                        <img src="images/spacer.gif" width="10" height="3"><br>                              
                        <a href="srform.htm"><img src="images/b_svcsreq.jpg" border="0"></a><br>            
                        <img src="images/spacer.gif" width="10" height="3"><br>                              
                        <img src="images/b_store.jpg" border="0"><br>      
                        <img src="images/spacer.gif" width="10" height="3"><br>                              
                        <a href="payment.htm"><img src="images/b_payment.jpg" border="0"></a><br>      
                        <img src="images/spacer.gif" width="10" height="3"><br>                              
                        <a href="empl.htm"><img src="images/b_empl.jpg" border="0"></a><br>      
                        <img src="images/spacer.gif" width="10" height="3"><br>                              
                        <a href="contact.htm"><img src="images/b_contact.jpg" border="0"></a><br>      
                        <img src="images/spacer.gif" width="10" height="3"><br>                              
                        <a href="links.htm"><img src="images/b_links.jpg" border="0"></a><br>                                                                                                                                          
                  </td>
                  <td><img src="images/spacer.gif" width="30" height="10">
                  </td>
                  <td valign="top" class="pt11">
                        <font color="red" size="3"><b>Please complete this form to request service or an estimate on a new system.
                        When you press "submit", the information will be emailed immediately to our scheduling department.
                        Please fill in all the fields for a prompt response</font><br><br>
                        <form method="POST"  name="sr_form" action="http://www.rkassociates.com/cgi-bin/procform-aja.pl">
                        <table width="70%" border="0" cellpadding="0" cellspacing="0" class="pt10">
                              <tr>
                                    <td colspan="4" bgcolor="black"><img src="images/spacer.gif" width="46" height="1"></td>
                              </tr>
                              <tr>
                                    <td colspan="4"><img src="images/spacer.gif" width="46" height="15"></td>
                              </tr>      
                              <tr>
                                    <td colspan="4">
                                          <table width="100%" cellpadding="0" cellspacing="0" border="0" class="pt10">
                                                <tr>
                                                      <td width="30%">First Name</td>
                                                      <td colspan="3" align="left"><input type="text" name="fname" style="background-color:'#E7F3DB'" size="32"></td>
                                                      <td align="right">Initial</td>
                                                      <td align="right"><input type="text" name="init" style="background-color:'#E7F3DB'" size="2"></td>
                                                </tr>
                                                <tr>
                                                      <td>Last Name</td>
                                                      <td colspan="5" align="right"><input type="text" name="lname" style="background-color:'#E7F3DB'" size="45"></td>
                                                </tr>                  
                                                <tr>
                                                      <td>Street Name</td>
                                                      <td colspan="5" align="right"><input type="text" name="addr1" style="background-color:'#E7F3DB'" size="45"></td>
                                                </tr>
                                                <tr>
                                                      <td>&nbsp;</td>
                                                      <td colspan="5" align="right"><input type="text" name="addr2" style="background-color:'#E7F3DB'" size="45"></td>
                                                </tr>
                                                <tr>
                                                      <td>City / Town</td>
                                                      <td colspan="5" align="right"><input type="text" name="city" style="background-color:'#E7F3DB'" size="45"></td>
                                                </tr>      
                                                <tr>
                                                      <td>State</td>
                                                      <td colspan="5" align="left"><input type="text" name="state" style="background-color:'#E7F3DB'" size="10">
                                                      <img src="images/spacer.gif" width="11" height="3">Zip&nbsp;<input type="text" name="zip" style="background-color:'#E7F3DB'" size="25"></td>
                                                </tr>                                                                                                                                                                                                                                                                        
                                          </table>
                                    </td>
                              </tr>                        

                              <tr>
                                    <td colspan="4"><img src="images/spacer.gif" width="46" height="15"></td>
                              </tr>                                    
                              <tr>
                                    <td colspan="4" bgcolor="black"><img src="images/spacer.gif" width="46" height="1"></td>
                              </tr>
                              <tr>
                                    <td colspan="4"><font color="red" size="3"><b>Contact Information</b><img src="images/spacer.gif" width="8" height="15"></td>
                              </tr>
                              <tr>
                                    <td colspan="4">Email Address<img src="images/spacer.gif" width="50" height="3"><input type="text" name="email" style="background-color:'#E7F3DB'" size="40"></td>
                              </tr>                  
                              <tr>
                                    <td colspan="4">Home Phone Number<img src="images/spacer.gif" width="50" height="3"><input type="text" name="hphone_ac" style="background-color:'#E7F3DB'" size="6">&nbsp;-&nbsp;<input type="text" name="hphone_ex" style="background-color:'#E7F3DB'" size="6">&nbsp;-&nbsp;<input type="text" name="hphone_l4" style="background-color:'#E7F3DB'" size="10"></td>
                              </tr>                        
                              <tr>
                                    <td colspan="4">Alt. Phone Number<img src="images/spacer.gif" width="64" height="3"><input type="text" name="aphone_ac" style="background-color:'#E7F3DB'" size="6">&nbsp;-&nbsp;<input type="text" name="aphone_ex" style="background-color:'#E7F3DB'" size="6">&nbsp;-&nbsp;<input type="text" name="aphone_l4" style="background-color:'#E7F3DB'" size="10"></td>
                              </tr>
                              <tr>
                                    <td colspan="4"><img src="images/spacer.gif" width="46" height="15"></td>
                              </tr>                                    
                              <tr>
                                    <td colspan="4" bgcolor="black"><img src="images/spacer.gif" width="46" height="1"></td>
                              </tr>
                              <tr>
                                    <td colspan="4"><img src="images/spacer.gif" width="46" height="15"></td>
                              </tr>                                          
                              <tr>
                                    <td colspan="4">
                                          <table width="100%" cellpadding="0" cellspacing="0">
                                                <tr>
                                                <td width="40%"class="pt10"><font color="red" size="3"><b>Type of Service</b></font><br><br>
                                                Please click service requested:<br><br>
                                                (You may select several by holding down the &lt;ctrl&gt; key)</td>
                                                <td width="60%" align="right"><select name="svcs" multiple style="background-color:'#E7F3DB';scrollbar-face-color:'red';scrollbar-track-color:'#FF9900';scrollbar-arrow-color:'yellow'" size="3">
                                                <option>System Service</option>
                                                <option>Spring Tune-up and Turn-On</option>
                                                <option>Winterization</option>
                                                <option>System Add-on or Enhancement</option>
                                                <option>Fertigation Refill / Install</option>
                                                <option>Landscape Lighting</option>
                                                <option>System Service</option>
                                                <option>Sales Estimate</option>
                                                <option>New System Installation</option>
                                                <option>Other</option></select></td>
                                                </tr>
                                          </table>
                                    </td>
                              </tr>      
                              <tr>
                                    <td colspan="4"><img src="images/spacer.gif" width="46" height="15"></td>
                              </tr>                                    
                              <tr>
                                    <td colspan="4" bgcolor="black"><img src="images/spacer.gif" width="46" height="1"></td>
                              </tr>
                              <tr>
                                    <td colspan="4"><img src="images/spacer.gif" width="46" height="15"></td>
                              </tr>
                              <tr>
                                    <td colspan="4">
                                          <table width="100%" cellpadding="0" cellspacing="0">
                                                <tr>
                                                <td width="40%"class="pt10" valign="top"><font color="red" size="3"><b>Suggested Scheduling Dates</b></font><br>
                                                Service will be scheduled based on these dates. Customers will be informed of actual
                                                scheduled date via email or phone.</td>
                                                <td width="60%" align="right" valign="middle">
                                                <textarea name="sdates" cols="25" rows="3" style="background-color:'#E7F3DB';scrollbar-face-color:'red';scrollbar-track-color:'#FF9900';scrollbar-arrow-color:'yellow'">
                                                </textarea>
                                                </td>
                                                </tr>
                                          </table>
                                    </td>
                              </tr>
                              <tr>
                                    <td colspan="4"><img src="images/spacer.gif" width="46" height="15"></td>
                              </tr>                                    
                              <tr>
                                    <td colspan="4" bgcolor="black"><img src="images/spacer.gif" width="46" height="1"></td>
                              </tr>
                              <tr>
                                    <td colspan="4"><img src="images/spacer.gif" width="46" height="15"></td>
                              </tr>                                    
                              <tr>
                                    <td colspan="4">
                                          <table width="100%" cellpadding="0" cellspacing="0">
                                                <tr>
                                                <td width="40%"class="pt10" valign="top"><font color="red" size="3"><b>Description of Other</b></font><br>
                                                Please conmplete if "other" selected</td>
                                                <td width="60%" align="right" valign="middle">
                                                <textarea name="other" cols="25" rows="3" style="background-color:'#E7F3DB';scrollbar-face-color:'red';scrollbar-track-color:'#FF9900';scrollbar-arrow-color:'yellow'">
                                                </textarea>
                                                </td>
                                                </tr>
                                          </table>
                                    </td>
                              </tr>
                              <tr>
                                    <td colspan="4"><img src="images/spacer.gif" width="46" height="15"></td>
                              </tr>                                    
                              <tr>
                                    <td colspan="4" bgcolor="black"><img src="images/spacer.gif" width="46" height="1"></td>
                              </tr>
                              <tr>
                                    <td colspan="4"><img src="images/spacer.gif" width="46" height="15"></td>
                              </tr>            
                              <tr>
                                    <td colspan="4" align="right"><input type="image" src="images/submit_green.jpg" border="0"><img src="images/spacer.gif" width="40" height="15"><img src="images/reset_orange.jpg" name="reset" onMousedown="do_reset();" border="0"></td>
                              </tr>                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
                        </table>
                        </form>
                  </td>
            </tr>      
            <tr>
                  <td colspan="2">&nbsp;</td>
                  <td colspan="3"><img src="images/greenline.gif"></td>
            </tr>
      </table>


</body>
</html>
0
 
LVL 10

Accepted Solution

by:
avidya earned 1000 total points
ID: 13850422
Hi, you gave the image the name "reset" which prevents the function to work.
reset is a function name

Change it like this
<img src="images/reset_orange.jpg" name="img_reset" onMousedown="do_reset
();" border="0"></td>

or delete the  name="reset" part if you don't need to address the image

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Suggested Courses
Course of the Month17 days, 11 hours left to enroll

830 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