Gopal2
asked on
reset javascript not working for dynamic text
Hi ,
I am using the following java script to generate a dependent text-box when "Other" is selected out of the dropdown for market type.
My issue is that, when I use reset link to reset the values, it's working for all the fileds except for the
"other market" text field that shows up when the "other" is selected from the market type dropdown.
I cannot see any reason why it won't work for the "other market" text field, when the same code works for text field fields like "email" and "phone number".
Thanks.
TEST.html
I am using the following java script to generate a dependent text-box when "Other" is selected out of the dropdown for market type.
My issue is that, when I use reset link to reset the values, it's working for all the fileds except for the
"other market" text field that shows up when the "other" is selected from the market type dropdown.
I cannot see any reason why it won't work for the "other market" text field, when the same code works for text field fields like "email" and "phone number".
Thanks.
TEST.html
i didnt find 'Company Type' drop down so i commented it.apart from this when you are givning names or id's to text boxes and dropdowns gdont use spaces in between the names;
use 'Company_Type' Other_Market
use 'Company_Type' Other_Market
check this on how to reset the form.
http://www.javascript-coder.com/javascript-form/javascript-reset-form.phtml
http://www.javascript-coder.com/javascript-form/javascript-reset-form.phtml
function clearForm(oForm) {
var frm_elements = document.forms[0].elements;
for (i = 0; i < frm_elements.length; i++)
{
field_type = frm_elements[i].type.toLowerCase();
switch (field_type)
{
case "text":
case "password":
case "textarea":
case "hidden":
frm_elements[i].value = "";
break;
case "radio":
case "checkbox":
if (frm_elements[i].checked)
{
frm_elements[i].checked = false;
}
break;
case "select-one":
case "select-multi":
frm_elements[i].selectedIndex = -1;
break;
default:
break;
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It was an issue of confusion because of the way the variables / labels were set up with the same name as per the requirements.That had to be worked on carefully to over come the confusion for the java script.
Open in new window