Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Searching about 40 text boxes?

anglicoanglico Posts: 8Member
Im trying to write a script that will check all the text boxes on a form against about 200 values that I plan on putting in a hidden field. I understand its not the best approach, but for my limited understanding of javascript it is all I can see until I can understand table access and or database connectivity.
I have searched for tutorials on this and cant find them, they are either way too complicated a form, or they arent even close to what I need. Obviously I dont want anyone to write it for me, I just need some pointers to some tutorials that will show me where Im going wrong.

INFO:
FormName: ChartsToCheck
Textboxes: tb_Chart1 - tb_Chart40

I assume I will set up a for loop that checks the tb_Chart1 - tb_Chart40 against the string of values in the hidden field, which right now is about 200 7 digit numbers. I want to eventually go to an array of chart numbers to check against so I can add and delete chart entries as needed.
Any help is appreciated. thank you.

Comments

  • zibadianzibadian Posts: 6,349Member
    : Im trying to write a script that will check all the text boxes on a form against about 200 values that I plan on putting in a hidden field. I understand its not the best approach, but for my limited understanding of javascript it is all I can see until I can understand table access and or database connectivity.
    : I have searched for tutorials on this and cant find them, they are either way too complicated a form, or they arent even close to what I need. Obviously I dont want anyone to write it for me, I just need some pointers to some tutorials that will show me where Im going wrong.
    :
    : INFO:
    : FormName: ChartsToCheck
    : Textboxes: tb_Chart1 - tb_Chart40
    :
    : I assume I will set up a for loop that checks the tb_Chart1 - tb_Chart40 against the string of values in the hidden field, which right now is about 200 7 digit numbers. I want to eventually go to an array of chart numbers to check against so I can add and delete chart entries as needed.
    : Any help is appreciated. thank you.
    :
    Since all the numbers are 7 digits, you can use the indexOf() method (http://w3schools.com/js/js_obj_string.asp) followed by the mod operator to see if the textbox value is in the string and it's location is divisible by 7. Example:
    Valid Values: 0123456 9876543
    Hidden: 01234569876543
    If the user enters 0123456, then the indexOf() will return 0, which is divisible by 7. If he enters 4569876, then indexOf() will return 4, which is not divisible by 7, thus an invalid value. Obviously a value of -1 is also invalid, since that's not in the string.
    This is not the fastest way, but it is one of the easiest to code.
  • anglicoanglico Posts: 8Member
    : : Im trying to write a script that will check all the text boxes on a form against about 200 values that I plan on putting in a hidden field. I understand its not the best approach, but for my limited understanding of javascript it is all I can see until I can understand table access and or database connectivity.
    : : I have searched for tutorials on this and cant find them, they are either way too complicated a form, or they arent even close to what I need. Obviously I dont want anyone to write it for me, I just need some pointers to some tutorials that will show me where Im going wrong.
    : :
    : : INFO:
    : : FormName: ChartsToCheck
    : : Textboxes: tb_Chart1 - tb_Chart40
    : :
    : : I assume I will set up a for loop that checks the tb_Chart1 - tb_Chart40 against the string of values in the hidden field, which right now is about 200 7 digit numbers. I want to eventually go to an array of chart numbers to check against so I can add and delete chart entries as needed.
    : : Any help is appreciated. thank you.
    : :
    : Since all the numbers are 7 digits, you can use the indexOf() method (http://w3schools.com/js/js_obj_string.asp) followed by the mod operator to see if the textbox value is in the string and it's location is divisible by 7. Example:
    : Valid Values: 0123456 9876543
    : Hidden: 01234569876543
    : If the user enters 0123456, then the indexOf() will return 0, which is divisible by 7. If he enters 4569876, then indexOf() will return 4, which is not divisible by 7, thus an invalid value. Obviously a value of -1 is also invalid, since that's not in the string.
    : This is not the fastest way, but it is one of the easiest to code.
    :
    Thank you for the help, the link was good, not exactly what I was looking for, but a good resource none the less, and they have a little spot to try stuff out, which is great, for me at least.
    Im thinking of running the values entered against the others in the hidden field, and I may make it another frame of the same document, and just iterate through both arrays with a for loop.

    document.form1.elements.textbox[0] /*what they entered*/ == document.form2.elements.textbox[0] /*Static list of charts to check against*/ then increase the array element in the form2 array until all are checked, then iterate the form1 array.

    Thank you again.
  • zibadianzibadian Posts: 6,349Member
    : : : Im trying to write a script that will check all the text boxes on a form against about 200 values that I plan on putting in a hidden field. I understand its not the best approach, but for my limited understanding of javascript it is all I can see until I can understand table access and or database connectivity.
    : : : I have searched for tutorials on this and cant find them, they are either way too complicated a form, or they arent even close to what I need. Obviously I dont want anyone to write it for me, I just need some pointers to some tutorials that will show me where Im going wrong.
    : : :
    : : : INFO:
    : : : FormName: ChartsToCheck
    : : : Textboxes: tb_Chart1 - tb_Chart40
    : : :
    : : : I assume I will set up a for loop that checks the tb_Chart1 - tb_Chart40 against the string of values in the hidden field, which right now is about 200 7 digit numbers. I want to eventually go to an array of chart numbers to check against so I can add and delete chart entries as needed.
    : : : Any help is appreciated. thank you.
    : : :
    : : Since all the numbers are 7 digits, you can use the indexOf() method (http://w3schools.com/js/js_obj_string.asp) followed by the mod operator to see if the textbox value is in the string and it's location is divisible by 7. Example:
    : : Valid Values: 0123456 9876543
    : : Hidden: 01234569876543
    : : If the user enters 0123456, then the indexOf() will return 0, which is divisible by 7. If he enters 4569876, then indexOf() will return 4, which is not divisible by 7, thus an invalid value. Obviously a value of -1 is also invalid, since that's not in the string.
    : : This is not the fastest way, but it is one of the easiest to code.
    : :
    : Thank you for the help, the link was good, not exactly what I was looking for, but a good resource none the less, and they have a little spot to try stuff out, which is great, for me at least.
    : Im thinking of running the values entered against the others in the hidden field, and I may make it another frame of the same document, and just iterate through both arrays with a for loop.
    :
    : document.form1.elements.textbox[0] /*what they entered*/ == document.form2.elements.textbox[0] /*Static list of charts to check against*/ then increase the array element in the form2 array until all are checked, then iterate the form1 array.
    :
    : Thank you again.
    :
    Something about that, but you need to look at the object properties. I don't think textbox is an array.
  • anglicoanglico Posts: 8Member
    : : : : Im trying to write a script that will check all the text boxes on a form against about 200 values that I plan on putting in a hidden field. I understand its not the best approach, but for my limited understanding of javascript it is all I can see until I can understand table access and or database connectivity.
    : : : : I have searched for tutorials on this and cant find them, they are either way too complicated a form, or they arent even close to what I need. Obviously I dont want anyone to write it for me, I just need some pointers to some tutorials that will show me where Im going wrong.
    : : : :
    : : : : INFO:
    : : : : FormName: ChartsToCheck
    : : : : Textboxes: tb_Chart1 - tb_Chart40
    : : : :
    : : : : I assume I will set up a for loop that checks the tb_Chart1 - tb_Chart40 against the string of values in the hidden field, which right now is about 200 7 digit numbers. I want to eventually go to an array of chart numbers to check against so I can add and delete chart entries as needed.
    : : : : Any help is appreciated. thank you.
    : : : :
    : : : Since all the numbers are 7 digits, you can use the indexOf() method (http://w3schools.com/js/js_obj_string.asp) followed by the mod operator to see if the textbox value is in the string and it's location is divisible by 7. Example:
    : : : Valid Values: 0123456 9876543
    : : : Hidden: 01234569876543
    : : : If the user enters 0123456, then the indexOf() will return 0, which is divisible by 7. If he enters 4569876, then indexOf() will return 4, which is not divisible by 7, thus an invalid value. Obviously a value of -1 is also invalid, since that's not in the string.
    : : : This is not the fastest way, but it is one of the easiest to code.
    : : :
    : : Thank you for the help, the link was good, not exactly what I was looking for, but a good resource none the less, and they have a little spot to try stuff out, which is great, for me at least.
    : : Im thinking of running the values entered against the others in the hidden field, and I may make it another frame of the same document, and just iterate through both arrays with a for loop.
    : :
    : : document.form1.elements.textbox[0] /*what they entered*/ == document.form2.elements.textbox[0] /*Static list of charts to check against*/ then increase the array element in the form2 array until all are checked, then iterate the form1 array.
    : :
    : : Thank you again.
    : :
    : Something about that, but you need to look at the object properties. I don't think textbox is an array.
    :
    So am I confused, I cant access it through the document.form.elements array? Since it is all textboxes, I figured that it would only be checking textboxes in the elements array. I typed it wrong above, it should have been document.form.elements[0] without the text.
  • zibadianzibadian Posts: 6,349Member
    : : : : : Im trying to write a script that will check all the text boxes on a form against about 200 values that I plan on putting in a hidden field. I understand its not the best approach, but for my limited understanding of javascript it is all I can see until I can understand table access and or database connectivity.
    : : : : : I have searched for tutorials on this and cant find them, they are either way too complicated a form, or they arent even close to what I need. Obviously I dont want anyone to write it for me, I just need some pointers to some tutorials that will show me where Im going wrong.
    : : : : :
    : : : : : INFO:
    : : : : : FormName: ChartsToCheck
    : : : : : Textboxes: tb_Chart1 - tb_Chart40
    : : : : :
    : : : : : I assume I will set up a for loop that checks the tb_Chart1 - tb_Chart40 against the string of values in the hidden field, which right now is about 200 7 digit numbers. I want to eventually go to an array of chart numbers to check against so I can add and delete chart entries as needed.
    : : : : : Any help is appreciated. thank you.
    : : : : :
    : : : : Since all the numbers are 7 digits, you can use the indexOf() method (http://w3schools.com/js/js_obj_string.asp) followed by the mod operator to see if the textbox value is in the string and it's location is divisible by 7. Example:
    : : : : Valid Values: 0123456 9876543
    : : : : Hidden: 01234569876543
    : : : : If the user enters 0123456, then the indexOf() will return 0, which is divisible by 7. If he enters 4569876, then indexOf() will return 4, which is not divisible by 7, thus an invalid value. Obviously a value of -1 is also invalid, since that's not in the string.
    : : : : This is not the fastest way, but it is one of the easiest to code.
    : : : :
    : : : Thank you for the help, the link was good, not exactly what I was looking for, but a good resource none the less, and they have a little spot to try stuff out, which is great, for me at least.
    : : : Im thinking of running the values entered against the others in the hidden field, and I may make it another frame of the same document, and just iterate through both arrays with a for loop.
    : : :
    : : : document.form1.elements.textbox[0] /*what they entered*/ == document.form2.elements.textbox[0] /*Static list of charts to check against*/ then increase the array element in the form2 array until all are checked, then iterate the form1 array.
    : : :
    : : : Thank you again.
    : : :
    : : Something about that, but you need to look at the object properties. I don't think textbox is an array.
    : :
    : So am I confused, I cant access it through the document.form.elements array? Since it is all textboxes, I figured that it would only be checking textboxes in the elements array. I typed it wrong above, it should have been document.form.elements[0] without the text.
    :
    Of course, you can use the elements[] array. A nested loop is always possible, although perhaps not the fastest. In pseudocode it would look something like this:
    [code]
    for i = 0 to document.form1.elements.count-1 do {
    for j = 0 to document.form2.elements.count-1 do {
    if document.form1.elements[i].value == document.form1.elements[j].value {
    Valid Code
    }
    }
    }
    if not is valid {
    Invalid Code
    }
    [/code]
    There are faster ways, like breaking out of the loops if a textbox has been found valid. The fastest way would be to use a binary search tree instead of an array as reference.
  • anglicoanglico Posts: 8Member
    : : : : : : Im trying to write a script that will check all the text boxes on a form against about 200 values that I plan on putting in a hidden field. I understand its not the best approach, but for my limited understanding of javascript it is all I can see until I can understand table access and or database connectivity.
    : : : : : : I have searched for tutorials on this and cant find them, they are either way too complicated a form, or they arent even close to what I need. Obviously I dont want anyone to write it for me, I just need some pointers to some tutorials that will show me where Im going wrong.
    : : : : : :
    : : : : : : INFO:
    : : : : : : FormName: ChartsToCheck
    : : : : : : Textboxes: tb_Chart1 - tb_Chart40
    : : : : : :
    : : : : : : I assume I will set up a for loop that checks the tb_Chart1 - tb_Chart40 against the string of values in the hidden field, which right now is about 200 7 digit numbers. I want to eventually go to an array of chart numbers to check against so I can add and delete chart entries as needed.
    : : : : : : Any help is appreciated. thank you.
    : : : : : :
    : : : : : Since all the numbers are 7 digits, you can use the indexOf() method (http://w3schools.com/js/js_obj_string.asp) followed by the mod operator to see if the textbox value is in the string and it's location is divisible by 7. Example:
    : : : : : Valid Values: 0123456 9876543
    : : : : : Hidden: 01234569876543
    : : : : : If the user enters 0123456, then the indexOf() will return 0, which is divisible by 7. If he enters 4569876, then indexOf() will return 4, which is not divisible by 7, thus an invalid value. Obviously a value of -1 is also invalid, since that's not in the string.
    : : : : : This is not the fastest way, but it is one of the easiest to code.
    : : : : :
    : : : : Thank you for the help, the link was good, not exactly what I was looking for, but a good resource none the less, and they have a little spot to try stuff out, which is great, for me at least.
    : : : : Im thinking of running the values entered against the others in the hidden field, and I may make it another frame of the same document, and just iterate through both arrays with a for loop.
    : : : :
    : : : : document.form1.elements.textbox[0] /*what they entered*/ == document.form2.elements.textbox[0] /*Static list of charts to check against*/ then increase the array element in the form2 array until all are checked, then iterate the form1 array.
    : : : :
    : : : : Thank you again.
    : : : :
    : : : Something about that, but you need to look at the object properties. I don't think textbox is an array.
    : : :
    : : So am I confused, I cant access it through the document.form.elements array? Since it is all textboxes, I figured that it would only be checking textboxes in the elements array. I typed it wrong above, it should have been document.form.elements[0] without the text.
    : :
    : Of course, you can use the elements[] array. A nested loop is always possible, although perhaps not the fastest. In pseudocode it would look something like this:
    : [code]
    : for i = 0 to document.form1.elements.count-1 do {
    : for j = 0 to document.form2.elements.count-1 do {
    : if document.form1.elements[i].value == document.form1.elements[j].value {
    : Valid Code
    : }
    : }
    : }
    : if not is valid {
    : Invalid Code
    : }
    : [/code]
    : There are faster ways, like breaking out of the loops if a textbox has been found valid. The fastest way would be to use a binary search tree instead of an array as reference.
    :
    WOW thank you, it helped me out alot!
  • mac_doggiemac_doggie Posts: 488Member
    : Im trying to write a script that will check all the text boxes on a form against about 200 values that I plan on putting in a hidden field. I understand its not the best approach, but for my limited understanding of javascript it is all I can see until I can understand table access and or database connectivity.
    : I have searched for tutorials on this and cant find them, they are either way too complicated a form, or they arent even close to what I need. Obviously I dont want anyone to write it for me, I just need some pointers to some tutorials that will show me where Im going wrong.
    :
    : INFO:
    : FormName: ChartsToCheck
    : Textboxes: tb_Chart1 - tb_Chart40
    :
    : I assume I will set up a for loop that checks the tb_Chart1 - tb_Chart40 against the string of values in the hidden field, which right now is about 200 7 digit numbers. I want to eventually go to an array of chart numbers to check against so I can add and delete chart entries as needed.
    : Any help is appreciated. thank you.
    :


    How about this?:

    [code]
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" />


    website - page

    function Check() {
    var textboxes = document.getElementsByTagName('input');

    for(var i=0;i





    [/code]
    ;-)
    -mac-
    mailto:mac_doggie@hotmail.com
    the Netherlands...


Sign In or Register to comment.