Results 1 to 18 of 18

Thread: Silly little problem

  1. #1

    Thread Starter
    Fanatic Member drpcken's Avatar
    Join Date
    Apr 2004
    Location
    devenv
    Posts
    591

    Silly little problem

    I have created a variable in my code, and I have a txtbox name txtHidden1. I want to fill the variable with the value of the txtbox but i dont' think I'm doing it right... Here's what I have now...

    Code:
    var varDNC
    varDNC = txtHidden1.name
    Very new to javascript, needed a feature that i couldn't do in VB.net and once this works it will be great!

    Thanks guys!

  2. #2
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    var myVar = document.getElementById('elementID').value
    Have I helped you? Please Rate my posts.

  3. #3

    Thread Starter
    Fanatic Member drpcken's Avatar
    Join Date
    Apr 2004
    Location
    devenv
    Posts
    591
    Awesome dude...

    But I'm getting an error in my IE that says Object Required when the page loads and the label doesn't show when it should.

    Here's my code, appreciate all your help!

    Code:
    <script language="javascript" type="text/javascript">
    function showDNC() {
    var varDNC = document.getElementById('Hidden1').value;
    }
    if (varDNC = 1) 
    {
    parent.topFrame.document.getElementById('lblDNC').style.visibility="visible"
    }
    else
    {
    parent.topFrame.document.getElementById('lblDNC').style.visibility="hidden"
    }
    </script>

  4. #4
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    Code:
    <script language="javascript" type="text/javascript">
    function showDNC() {
    var varDNC = document.getElementById('Hidden1').value;
    } 
    if (varDNC ==  1) 
    {
    parent.topFrame.document.getElementById('lblDNC').style.visibility="visible"
    }
    else
    {
    parent.topFrame.document.getElementById('lblDNC').style.visibility="hidden"
    }
    </script>
    The } marked in red end the function. Are you sure you wanted that?

    Also language="javascript" should not be there, it servs no purpose.


    Edit: This could also be happening in the bottom frame loads and runs the function before that textbox has loaded up in the top frame. There are ways to sort this out. but first see if it works as it is, to see if we need to fix this.

    2nd Edit: I added another equals into the IF statement, you need two equals in JS, unlike ASP. One will set the value equals to the right hand side, two will check to see if the are the same.
    Last edited by Acidic; Oct 19th, 2004 at 01:57 PM.
    Have I helped you? Please Rate my posts.

  5. #5

    Thread Starter
    Fanatic Member drpcken's Avatar
    Join Date
    Apr 2004
    Location
    devenv
    Posts
    591
    The textbox is in the same frame as this code.

    And with these changes, I only get the error once, before I was getting it twice. here's the code I updated...

    Code:
    <script type="text/javascript">
    function showDNC() {
    var varDNC = document.getElementById('Hidden1').value;
    
    if (varDNC = 1) 
    {
    parent.topFrame.document.getElementById('lblDNC').style.visibility="visible"
    }
    else
    {
    parent.topFrame.document.getElementById('lblDNC').style.visibility="hidden"
    }
    }
    </script>

  6. #6
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    If it's in the same frame, then you can simplify:
    parent.topFrame.document.getElementById('lblDNC').style.visibility
    to:
    document.getElementById('lblDNC').style.visibility

    also, read my second edit. I changed the IF to have two ='s
    Have I helped you? Please Rate my posts.

  7. #7

    Thread Starter
    Fanatic Member drpcken's Avatar
    Join Date
    Apr 2004
    Location
    devenv
    Posts
    591
    sweet changed the ==

    also just to let you know, the only thing in the top frame i'm manipulating in this code is the lblDNC, or the lines

    Code:
    parent.topFrame.document.getElementById('lblDNC').style.visibility="visible"
    and

    Code:
    parent.topFrame.document.getElementById('lblDNC').style.visibility="hidden"
    Everything else, such as the Hidden1 textbox, is in the same frame as the javascript being written.


    same object required error

  8. #8
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    The text box does have id="Hidden1" right? not name="Hidden1" or that the case is wrong. Unless that was the error, post me the code for the entire page please. Not including ASP, just the outputted HTML.

    Same applies for the element whose visibility you're changing.
    Have I helped you? Please Rate my posts.

  9. #9

    Thread Starter
    Fanatic Member drpcken's Avatar
    Join Date
    Apr 2004
    Location
    devenv
    Posts
    591
    Code:
    <!--ASPX page @1-D4120D99-->
        
    
    <html>
    <head>
    <title>Prospects Main</title>
    <link rel="stylesheet" type="text/css" href="Themes/DeepWater/Style.css">
    <script language="JavaScript" type="text/javascript">
    //Begin CCS script
    //End CCS script
    </script>
    
    
    
    <script type="text/javascript">
    function showDNC() {
    var varDNC = document.getElementById('ProspectsMainHidden1').value;
    
    if (varDNC == 1) 
    {
    parent.topFrame.document.getElementById('lblDNC').style.visibility="visible"
    }
    else
    {
    parent.topFrame.document.getElementById('lblDNC').style.visibility="hidden"
    }
    }
    </script>
    
    
    
    </head>
    <body onLoad="showDNC()" bgcolor="#39597b" link="#000000" alink="#ff0000" vlink="#000099" text="#ffffff" class="DeepWaterPageBODY">
    
    <font class="DeepWaterFormHeaderFont">&nbsp;Prospects/Family &nbsp;Main<input name="ProspectsMainHidden1" id="ProspectsMainHidden1" type="hidden" value="0" /></font> 
      <table cellpadding="3" cellspacing="0" border="0" bgcolor="#5a7994" style="BORDER-RIGHT: #9db4c8 2px solid; BORDER-TOP: #9db4c8 2px solid; BORDER-LEFT: #9db4c8 2px solid; BORDER-BOTTOM: #9db4c8 2px solid">

  10. #10
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    Is that all the HTML? There are no elements with those IDs, that's whats causing the error.
    Have I helped you? Please Rate my posts.

  11. #11

    Thread Starter
    Fanatic Member drpcken's Avatar
    Join Date
    Apr 2004
    Location
    devenv
    Posts
    591
    I was just showing you the html with the javascript code, and the textbox that i'm pulling the value into my var.

    the lblDNC is in the top frame by the way.

    What do you mean by elements?

  12. #12
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    by element I mean an HTML element, ie <img> <input> <a> etc.

    Since it's in the top frame, please post the HTMl code for that.
    Have I helped you? Please Rate my posts.

  13. #13

    Thread Starter
    Fanatic Member drpcken's Avatar
    Join Date
    Apr 2004
    Location
    devenv
    Posts
    591
    Ok here's the output html from the top page, but i notice it doesn't have my lblDNC that suppose to be there....


    Code:
    
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="refresh" content="600">
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link href="css/maincounselor.css" rel="stylesheet" type="text/css">
    <style type="text/css">
    <!--
    .style3 {
    	color: #FFFFFF;
    	font-family: Arial, Helvetica, sans-serif;
    }
    -->
    </style>
    <script language="JavaScript">
    <!--
    function mmLoadMenus() {
      
    if (window.mm_menu_0815151236_0) return;
      window.mm_menu_0815151236_0 = new Menu("root",101,18,"Arial, Helvetica, 
    
       mm_menu_0916162538_0.writeMenus();
    } // mmLoadMenus()
    //-->
    </script>
    <script language="JavaScript" src="mm_menu.js"></script>
    </head>
    
    <body>
    <script language="JavaScript1.2">mmLoadMenus();</script>
    
    
    <form name="_ctl0" method="post" action="topcounselor.aspx" id="_ctl0">
    
    <span class="style3"> <img src="images/IFPAsmall.jpg" width="240" height="110" border="1" align="left">&nbsp;Welcome </span>
    <span id="lblName" Font-color="white" style="color:White;font-family:Arial,Geneva;font-size:12pt;font-weight:bold;">Arlene Harder                                                    </span>&nbsp;&nbsp;&nbsp;
    <font color="#9DB4C8" face = "Arial"><small><b><a style="text-decoration:none; color:#9DB4C8" href="login.aspx" target="_top">Logout</a></b></small></font>
    <br> 
    <span class="style3"> &nbsp;Today's date is </span>
    <span id="lblDate" Font-color="white" style="color:White;font-family:Arial,Geneva;font-size:12pt;font-weight:bold;">10/19/2004</span>
    <br>
    <span class="style3"> &nbsp;You have </span> <a style="text-decoration:none"href="MessageCheck.aspx?refresh=001" target="mainFrame">
    <span id="lblMsgCount" Font-color="white" style="color:White;font-family:Arial,Geneva;font-size:12pt;font-weight:bold;">0</span>
    <span class="style3"> new message(s). </span></a><br>
    <br>
    <br>
    <span class="style3" ></span>
    </form>
    <br>
    </body>
    </html>

  14. #14
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    Originally posted by drpcken
    but i notice it doesn't have my lblDNC that suppose to be there....
    Well, there you go. That's your error. It's changing the visibility of a non-existing element.
    Have I helped you? Please Rate my posts.

  15. #15

    Thread Starter
    Fanatic Member drpcken's Avatar
    Join Date
    Apr 2004
    Location
    devenv
    Posts
    591
    Code:
    <span class="style3" ><asp:Label ID="lblDNC" Text="DO NOT CALL this prospect!" runat="server" /></span>

    This is the code from dreamweaver, same file only from the source. The first bit I sent was from the outputted HTML when I view source in IE.


    Any ideas?

  16. #16
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    I have no clue as to ASP. Sorry. Why can't you just write that part as normal HTML though? You don't seem to be printing off any ASP variables, so why not just make it normal HTML, not ASP?

    edit: that was my 210th post.

    2nd edit: if this turns out to be an ASP issue, then there is a seperate ASP forum.
    Have I helped you? Please Rate my posts.

  17. #17

    Thread Starter
    Fanatic Member drpcken's Avatar
    Join Date
    Apr 2004
    Location
    devenv
    Posts
    591
    I think I'm going to have to just dump my frames, and create headers out of all my top frame pages.

    Thanks for all your help!

  18. #18
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    Frames are pointeless. CSS can replicate all the effects frames create. Though IE doesn't support position: static; yet.

    But this can still work using frames. Just ask in the asp section why the element doesn't appear in the HTML source.
    Have I helped you? Please Rate my posts.

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