Results 1 to 9 of 9

Thread: Javascript error

  1. #1

    Thread Starter
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861

    Resolved Javascript error

    I have a form where I check a ranking of an item, if the items rank is greater than 0, then I want to display a hidden table cell. Here is how I am doing it, but it isn't working.
    Can anyone tell me what the problem is???
    VB Code:
    1. 'The function to show or hide the cell in the table
    2. function CheckRanking(RankValue, elementTag)
    3. {
    4.     if(RankValue >= 1)
    5.     {
    6.         document.forms[0].getElementById(elementTag).style.visibility ='visible';
    7.     }
    8.     else
    9.     {
    10.         document.forms[0].getElementById(elementTag).style.display = 'none';
    11.     }
    12. }
    13.  
    14. 'This is the row where the item is ranked
    15. <td class="ESP_Data_Border" ><input maxlength="3" size="4" name="txtPriority" value="0" OnBlur="CheckRanking(this.value, 'ENHANCEMENTVERSION_B4370631-06B8-4DE4-864A-021ACDAD3087');"></td>
    16.  
    17. 'This is the cell that should show or hide based on the rank entered into the cell above
    18. <td id="ENHANCEMENTVERSION_B437063106B84DE4864A021ACDAD3087" class="ESP_Data_Border" STYLE="visibility: hidden"><select name="lstVersions"><option>HERE ARE THE VERSIONS</option></select></td>
    but I keep getting a "object doesn't support this property or method" error.
    Last edited by Memnoch1207; Nov 8th, 2004 at 12:56 PM.
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    getElementById only exists on the document object itself.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    okay, I took out the forms[0] and now I get "Object Required" error.
    VB Code:
    1. function CheckRanking(RankValue, elementTag)
    2. {
    3.     if(RankValue >= 1)
    4.     {
    5.         document.getElementById(elementTag).style.visibility ='visible';
    6.     }
    7.     else
    8.     {
    9.         document.getElementById(elementTag).style.display = 'none';
    10.     }
    11. }
    12.  
    13. 'This is the row where the item is ranked
    14. <td class="ESP_Data_Border" ><input maxlength="3" size="4" name="txtPriority" value="0" onBlur="CheckRanking(this.value, 'ENHANCEMENTVERSION_B4370631-06B8-4DE4-864A-021ACDAD3087');"></td>
    15.  
    16. 'This is the cell that should show or hide based on the rank entered into the cell above
    17. <td id="ENHANCEMENTVERSION_B437063106B84DE4864A021ACDAD3087" class="ESP_Data_Border" STYLE="visibility: hidden"><select name="lstVersions"><option>HERE ARE THE VERSIONS</option></select></td>
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    I don't know why. But are you aware that your show and hide lines don't counteract each other?

    Also, what browsers are you testing in?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    you are making the argument a string right? not an object itself.
    Have I helped you? Please Rate my posts.

  6. #6

    Thread Starter
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    Here's what I have.
    VB Code:
    1. function CheckRanking(RankValue, elementTag)
    2. {
    3.     if(RankValue >= 1)
    4.     {
    5.         document.getElementById(elementTag).style.display ='';
    6.     }
    7.     else
    8.     {
    9.         document.getElementById(elementTag).style.display = 'none';
    10.     }
    11. }
    12.  
    13. [color=red]This column determines if the next column should be shown or hidden[/color]
    14. <td class="ESP_Data_Border" ><input maxlength="3" size="4" name="txtPriority" value="0" OnBlur="CheckRanking(this.value, 'ENHANCEMENTVERSION_E9AAD463-70D2-4EAE-A3C6-E296F6AC9E94');"></td>
    15.  
    16. [color=red]Column to be shown/hidden[/color]
    17. <td id="ENHANCEMENTVERSION_E9AAD46370D24EAEA3C6E296F6AC9E94" class="ESP_Data_Border" STYLE="visibility: hidden"><input type="hidden" name="varVersionEnhancementID" value="{E9AAD463-70D2-4EAE-A3C6-E296F6AC9E94}"><select name="lstVersions"><option>HERE ARE THE VERSIONS</option></select></td>
    If the value of the text box is greater than or equal to 1, then I want the second column to be displayed, so the user can select the correct option from the dropdown.

    When I do an alert on either of the variables passed, they work fine. But I get an "Object Required" error when the code runs.
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  7. #7
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    What does
    alert(document.getElementById(elementTag));
    output?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  8. #8
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    Shouldn't ENHANCEMENTVERSION_E9AAD463-70D2-4EAE-A3C6-E296F6AC9E94 equal the id of the next element?
    Have I helped you? Please Rate my posts.

  9. #9

    Thread Starter
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    Problem solved.
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width