Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RESET form 1

Status
Not open for further replies.

A1Pat

IS-IT--Management
Jun 7, 2004
454
US
hello,
I'm trying to clear up a form when Reset button clicked; however, this SELECT box keeps stay the same with value that I selected recently.
I included the following code in a reset function to reset the box to value (0) "Make your selection" but no luck:

Code:
mySDK.Channel.value = "0";
mySDK.Channel.options[0].text = "";	
mySDK.Channel.options[0].value = 0;

is there another way?
 
Code:
mySDK.Channel.selectedIndex = 0;

-kaht

Looking for a puppy? [small](Silky Terriers are hypoallergenic dogs that make great indoor pets due to their lack of shedding and small size)[/small]
 
I don't know what exactly is going on, but assuming you want the select box back to it's 0 index value, do this instead of what you have typed above:


Code:
mySDK.Channel.selectedIndex = 0;

[small]"Mom........MEATLOAF!!!! F***!!!!"[/small]
<.
 
thank kaht and monksnake for your replies.

I pasted the code to the function and retested, the result is still the same.

Is there anything else you need to review for further understanding?

One thing I know for sure is when I refresh the page, everything is reset to the original. I wonder if telling the page to refresh when reset button clicked is workable.
 
Is that what you are looking for - something that will reset the page back to it's default values that were set when the page loaded? If so, there's a javascript function that already does this:

Code:
document.reset()

-kaht

Looking for a puppy? [small](Silky Terriers are hypoallergenic dogs that make great indoor pets due to their lack of shedding and small size)[/small]
 
Is not working kaht...

This is what I got:
Code:
funtion pgReset()
{
document.reset();
}

is that correct?
 
Do you have funtion or function written in your code?

[small]"Mom........MEATLOAF!!!! F***!!!!"[/small]
<.
 
Sorry, I had a brain fart - reset() is a form method, it resets all the elements in that form. Here's an example, change any of the values and click the reset button to set them back to the initial values:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<script type="text/javascript"></script>
<style type="text/css"></style>
</head>
<body>

<form id="blah">
   <input type="text" value="the textbox" /><br />
   <select>
      <option>1</option>
      <option selected="selected">2</option>
      <option>3</option>
   </select><br />
   <textarea>default textarea value</textarea><br />
   <input type="button" value="reset form" onclick="document.getElementById('blah').[!]reset()[/!]" />
</form>

</body>
</html>

-kaht

Looking for a puppy? [small](Silky Terriers are hypoallergenic dogs that make great indoor pets due to their lack of shedding and small size)[/small]
 
kaht,

Can't the onClick function allow to have more than 1 calling when clicked? I meant, my button already told the program to do one thing (more than just reset the form) already... can I add the line document.getElementById('blah').reset() into the same onClick button?

thanks!
 
to monksnake,
could you elaborate your question a little more? I maybe misunderstood your question somehow.
 
Put a semicolon between commands:
Code:
<input type="button" value="reset form" onclick="document.getElementById('blah').reset()[!];alert('test')[/!]" />

-kaht

Looking for a puppy? [small](Silky Terriers are hypoallergenic dogs that make great indoor pets due to their lack of shedding and small size)[/small]
 
AHA!!!!

alright kaht!!! You did it!

I add the line to my onClick="document.getElementById('myform').reset(); Do_DisConnect();", and it works like a charm...

thanks all for the help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top