Advertisement

[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

09/29/2003 at 08:43AM PDT, ID: 20751894
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.2

How to create an array text box to lessen the codes

Asked by lin100 in JavaScript

Tags: array, box, text

How to create an array text box to lessen the codes
===========================================

I have a total of four IP addresses that may (optional not mandatory) to be filled in.
Each Ip address have four separate fields. This gives a total
of 16 fields. The code below showed that codes has to be
written for these individual fields.

1) Is there a way to declared in HTML that these fields are arrays
so that I could access them by subscript (ex: array[1] to array[16]) to lessen the codes ?

===========================================
[code]
<script LANGUAGE="Javascript">
<!--

function check_for_all_0_and_all_255(ip_address)
{

  if (ip_address.name == "ip1" ||ip_address.name == "ip2" ||
      ip_address.name == "ip3" ||ip_address.name == "ip4")
    {
      field_name_1 = "ip1";
      field_name_2 = "ip2";
      field_name_3 = "ip3";
      field_name_4 = "ip4";
    }

  if (ip_address.name == "ip1opt" ||ip_address.name == "ip2opt" ||
      ip_address.name == "ip3opt" ||ip_address.name == "ip4opt")
    {
      field_name_1 = "ip1opt";
      field_name_2 = "ip2opt";
      field_name_3 = "ip3opt";
      field_name_4 = "ip4opt";
    }

  if (ip_address.name == "ip1opt1" ||ip_address.name == "ip2opt1" ||
      ip_address.name == "ip3opt1" ||ip_address.name == "ip4opt1")
    {
      field_name_1 = "ip1opt1";
      field_name_2 = "ip2opt1";
      field_name_3 = "ip3opt1";
      field_name_4 = "ip4opt1";

    }

  if (ip_address.name == "ip1opt2" ||ip_address.name == "ip2opt2" ||
      ip_address.name == "ip3opt2" ||ip_address.name == "ip4opt2")
    {
      field_name_1 = "ip1opt2";
      field_name_2 = "ip2opt2";
      field_name_3 = "ip3opt2";
      field_name_4 = "ip4opt2";

  converted_ip1 = parseInt(document.form1[field_name_1].value)
  converted_ip2 = parseInt(document.form1[field_name_2].value)
  converted_ip3 = parseInt(document.form1[field_name_3].value)
  converted_ip4 = parseInt(document.form1[field_name_4].value)

  if (converted_ip1 == 0 && converted_ip2 == 0 && converted_ip3 == 0 && converted_ip4 == 0)
    {
      alert ("The IP value cannot be 0.0.0.0");
      document.form1[field_name_1].value = "";
      document.form1[field_name_2].value = "";
      document.form1[field_name_3].value = "";
      document.form1[field_name_4].value = "";
      return false;
    }

  if (converted_ip1 == 255 && converted_ip2 == 255 && converted_ip3 == 255 && converted_ip4 == 255)
    {
      alert ("The IP value cannot be 255.255.255.255");
      document.form1[field_name_1].value = "";
      document.form1[field_name_2].value = "";
      document.form1[field_name_3].value = "";
      document.form1[field_name_4].value = "";
      return false;
    }
}

  <input type=text size=3 maxlength=3 name=ip1 onkeyup='only_numbers(ip1)' onblur='check_for_over_255(ip1); check_for_all_0_and_all_255(ip1)' value="<?=$lv_ip01?>">&nbsp;<b>.</b>
  <input type=text size=3 maxlength=3 name=ip2 onkeyup='only_numbers(ip2)' onblur='check_for_over_255(ip2); check_for_all_0_and_all_255(ip2)' value="<?=$lv_ip02?>">&nbsp;<b>.</b>
  <input type=text size=3 maxlength=3 name=ip3 onkeyup='only_numbers(ip3)' onblur='check_for_over_255(ip3); check_for_all_0_and_all_255(ip3)' value="<?=$lv_ip03?>">&nbsp;<b>.</b>
  <input type=text size=3 maxlength=3 name=ip4 onkeyup='only_numbers(ip4)' onblur='check_for_over_255(ip4); check_for_all_0_and_all_255(ip4)' value="<?=$lv_ip04?>">
  </td>

//-->
</SCRIPT>

[/code]View the Solution FREE for 30 Days
[+][-]09/29/03 08:45 AM, ID: 9452364

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/29/03 09:30 AM, ID: 9452641

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]09/29/03 09:38 AM, ID: 9452687

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: JavaScript
Tags: array, box, text
Sign Up Now!
Solution Provided By: mark-b
Participating Experts: 3
Solution Grade: A
 
 
[+][-]09/29/03 09:39 AM, ID: 9452696

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/29/03 10:17 AM, ID: 9452947

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/29/03 12:08 PM, ID: 9453824

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/29/03 12:35 PM, ID: 9454031

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/29/03 01:46 PM, ID: 9454566

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/29/03 02:09 PM, ID: 9454793

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/29/03 02:19 PM, ID: 9454870

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20090429-EE-VQP-58