tricky javascript problem requires javascript guru !

Discussion in 'Javascript' started by Andy, Mar 4, 2004.

  1. Andy

    Andy Guest

    Hi,

    I am complete JavaScript novice and would really appreciate some help with
    this code:

    =====================================================================

    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>

    <!--#include file="Connections/ssdb.asp" -->
    <%
    Dim rs_news_edit
    Dim rs_news_edit_numRows

    Set rs_news_edit = Server.CreateObject("ADODB.Recordset")
    rs_news_edit.ActiveConnection = MM_ssdb_STRING
    rs_news_edit.Source = "SELECT * FROM tblnews"
    rs_news_edit.CursorType = 0
    rs_news_edit.CursorLocation = 2
    rs_news_edit.LockType = 1
    rs_news_edit.Open()

    rs_news_edit_numRows = 0
    %>
    <%
    Dim Repeat1__numRows
    Dim Repeat1__index

    Repeat1__numRows = -1
    Repeat1__index = 0
    rs_news_edit_numRows = rs_news_edit_numRows + Repeat1__numRows
    %>
    <%
    Dim MM_paramName
    %>
    <%
    ' *** Go To Record and Move To Record: create strings for maintaining URL
    and Form parameters

    Dim MM_keepNone
    Dim MM_keepURL
    Dim MM_keepForm
    Dim MM_keepBoth

    Dim MM_removeList
    Dim MM_item
    Dim MM_nextItem

    ' create the list of parameters which should not be maintained
    MM_removeList = "&index="
    If (MM_paramName <> "") Then
    MM_removeList = MM_removeList & "&" & MM_paramName & "="
    End If

    MM_keepURL=""
    MM_keepForm=""
    MM_keepBoth=""
    MM_keepNone=""

    ' add the URL parameters to the MM_keepURL string
    For Each MM_item In Request.QueryString
    MM_nextItem = "&" & MM_item & "="
    If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then
    MM_keepURL = MM_keepURL & MM_nextItem &
    Server.URLencode(Request.QueryString(MM_item))
    End If
    Next

    ' add the Form variables to the MM_keepForm string
    For Each MM_item In Request.Form
    MM_nextItem = "&" & MM_item & "="
    If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then
    MM_keepForm = MM_keepForm & MM_nextItem &
    Server.URLencode(Request.Form(MM_item))
    End If
    Next

    ' create the Form + URL string and remove the intial '&' from each of the
    strings
    MM_keepBoth = MM_keepURL & MM_keepForm
    If (MM_keepBoth <> "") Then
    MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1)
    End If
    If (MM_keepURL <> "") Then
    MM_keepURL = Right(MM_keepURL, Len(MM_keepURL) - 1)
    End If
    If (MM_keepForm <> "") Then
    MM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)
    End If

    ' a utility function used for adding additional parameters to these strings
    Function MM_joinChar(firstItem)
    If (firstItem <> "") Then
    MM_joinChar = "&"
    Else
    MM_joinChar = ""
    End If
    End Function
    %>
    <html>
    <head>
    <title>ss</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

    <style>
    ..showSwitch {
    display: block;
    font-family: Georgia, "Times New Roman", Times, serif;
    color: #FF0000;
    }
    ..hideSwitch {
    display: none;
    font-family: Georgia, "Times New Roman", Times, serif;
    color: #FF0000;
    }
    </style>

    <script>

    function showHideSwitch2 (theid, value) {
    if (document.getElementById) {
    switch_id = document.getElementById(theid);
    if (value == 'show') {
    switch_id.className = 'showSwitch';
    }else{ switch_id.className = 'hideSwitch';
    }
    }
    }

    </script>


    <style type="text/css">
    <!--
    -->
    </style>

    </head>
    <body background="Images/BG.jpg">
    <table width="100%" height="100%" border="0" align="center" cellpadding="0"
    cellspacing="0">
    <tr>
    <td align="center" valign="middle">
    <table width="700" height="600" border="1" align="center" cellpadding="0"
    cellspacing="0" bordercolor="#B1D3EC">
    <tr>
    <td bgcolor="#FFFFFF">
    <table width="100%" height="100%" border="0" align="center"
    cellpadding="0" cellspacing="0">
    <tr>
    <td><div align="left">&nbsp;&nbsp;&nbsp;&nbsp;<img
    src="Images/edit_news.jpg" width="142" height="40"></div></td>
    </tr>
    <tr>
    <td><p align="center">&nbsp;</p>
    <p align="left">&nbsp;</p>
    <table width="95%" border="0" align="center"
    cellpadding="0" cellspacing="0">
    <%
    While ((Repeat1__numRows <> 0) AND (NOT rs_news_edit.EOF))
    %>
    <tr>
    <td width="28%"><p
    align="left"><%=(rs_news_edit.Fields.Item("news_summary").Value)%></p>
    <p>&nbsp;</p></td>
    <td width="28%"><div align="center">

    <p><%=(rs_news_edit.Fields.Item("news_complete").Value)%></p>
    <p>&nbsp;</p>
    </div></td>
    <td width="28%">&nbsp;</td>
    <td width="16%">
    <div align="center">
    <p align="right"><a href="edit_news_01.asp?<%=
    MM_keepURL & MM_joinChar(MM_keepURL) & "id=" &
    rs_news_edit.Fields.Item("id").Value %>">Change</a>
    </p>
    <p>&nbsp; </p>
    </div></td>
    </tr>
    <tr>
    <td colspan="4"><p align="left"><a href="javascript:;"
    onClick="showHideSwitch2('switch4', 'show')">open
    4</a>
    <a href="javascript:;" onClick="showHideSwitch2('switch4', 'hide')">close
    4</a>
    <p class="hideSwitch" id="switch4"><table width="75%" border="1"
    align="center">
    <tr>
    <td>1</td>
    <td>1</td>
    <td>1</td>
    </tr>
    <tr>
    <td>1</td>
    <td>1</td>
    <td>1</td>
    </tr>
    <tr>
    <td>1</td>
    <td>1</td>
    <td>1</td>
    </tr>
    </table></p></p>
    </td>
    </tr>
    <tr>
    <td colspan="4"><hr></td>
    </tr>
    <tr>
    <td colspan="4">&nbsp;</td>
    </tr>
    <%
    Repeat1__index=Repeat1__index+1
    Repeat1__numRows=Repeat1__numRows-1
    rs_news_edit.MoveNext()
    Wend
    %>
    </table>
    <p align="center">&nbsp;</p>
    <p align="center">&nbsp;</p>
    <p align="center">&nbsp;</p>
    <p align="center">&nbsp;</p>
    <p align="center">&nbsp;</p></td>
    </tr>
    </table></td>
    </tr>
    <tr>
    <td height="10" bgcolor="#B1D3EC">&nbsp;</td>
    </tr>
    </table></td>
    </tr>
    </table>
    </body>
    </html>
    <%
    rs_news_edit.Close()
    Set rs_news_edit = Nothing
    %>


    =====================================================================

    The problem is that the table with the '1's in it does not appear in each
    repeat region bit, so for example if you clicked on the 5th repeated region
    section the table would still open in the first section with the included
    dynamic data also from the first item

    Is there anyway I can fix this ?

    Thanks in advance,

    Andy.
     
    Andy, Mar 4, 2004
    #1
    1. Advertising

  2. Andy

    Andy Guest

    Hi Andrew,

    The VBscript is for the ASP code, there is a little JavaScript within
    section of code that controls the show hide aspect of website, its this I
    hope to fix.

    Thanks

    Andy.

    "Andrew Urquhart" <> wrote in message
    news:6pL1c.650$54.540@newsfe1-win...
    > Andy wrote:
    > > Hi,
    > >
    > > I am complete JavaScript novice and would really appreciate some help
    > > with this code:
    > >
    > > =====================================================================
    > >
    > > <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    > >
    > > <!--#include file="Connections/ssdb.asp" -->
    > > <%
    > > Dim rs_news_edit
    > > Dim rs_news_edit_numRows
    > >
    > > Set rs_news_edit = Server.CreateObject("ADODB.Recordset")
    > > rs_news_edit.ActiveConnection = MM_ssdb_STRING
    > > rs_news_edit.Source = "SELECT * FROM tblnews"
    > > rs_news_edit.CursorType = 0
    > > rs_news_edit.CursorLocation = 2
    > > rs_news_edit.LockType = 1
    > > rs_news_edit.Open()
    > >
    > > rs_news_edit_numRows = 0
    > > %>
    > > <%
    > > Dim Repeat1__numRows
    > > Dim Repeat1__index
    > >
    > > Repeat1__numRows = -1
    > > Repeat1__index = 0
    > > rs_news_edit_numRows = rs_news_edit_numRows + Repeat1__numRows
    > > %>
    > > <%
    > > Dim MM_paramName
    > > %>
    > > <%
    > > ' *** Go To Record and Move To Record: create strings for maintaining
    > > URL and Form parameters
    > >
    > > Dim MM_keepNone
    > > Dim MM_keepURL
    > > Dim MM_keepForm
    > > Dim MM_keepBoth
    > >
    > > Dim MM_removeList
    > > Dim MM_item
    > > Dim MM_nextItem
    > >
    > > ' create the list of parameters which should not be maintained
    > > MM_removeList = "&index="
    > > If (MM_paramName <> "") Then
    > > MM_removeList = MM_removeList & "&" & MM_paramName & "="
    > > End If
    > >
    > > MM_keepURL=""
    > > MM_keepForm=""
    > > MM_keepBoth=""
    > > MM_keepNone=""
    > >
    > > ' add the URL parameters to the MM_keepURL string
    > > For Each MM_item In Request.QueryString
    > > MM_nextItem = "&" & MM_item & "="
    > > If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then
    > > MM_keepURL = MM_keepURL & MM_nextItem &
    > > Server.URLencode(Request.QueryString(MM_item))
    > > End If
    > > Next
    > >
    > > ' add the Form variables to the MM_keepForm string
    > > For Each MM_item In Request.Form
    > > MM_nextItem = "&" & MM_item & "="
    > > If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then
    > > MM_keepForm = MM_keepForm & MM_nextItem &
    > > Server.URLencode(Request.Form(MM_item))
    > > End If
    > > Next
    > >
    > > ' create the Form + URL string and remove the intial '&' from each of
    > > the strings
    > > MM_keepBoth = MM_keepURL & MM_keepForm
    > > If (MM_keepBoth <> "") Then
    > > MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1)
    > > End If
    > > If (MM_keepURL <> "") Then
    > > MM_keepURL = Right(MM_keepURL, Len(MM_keepURL) - 1)
    > > End If
    > > If (MM_keepForm <> "") Then
    > > MM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)
    > > End If
    > >
    > > ' a utility function used for adding additional parameters to these
    > > strings Function MM_joinChar(firstItem)
    > > If (firstItem <> "") Then
    > > MM_joinChar = "&"
    > > Else
    > > MM_joinChar = ""
    > > End If
    > > End Function
    > > %>
    > > <html>
    > > <head>
    > > <title>ss</title>
    > > <meta http-equiv="Content-Type" content="text/html;
    > > charset=iso-8859-1">
    > >
    > > <style>
    > > .showSwitch {
    > > display: block;
    > > font-family: Georgia, "Times New Roman", Times, serif;
    > > color: #FF0000;
    > > }
    > > .hideSwitch {
    > > display: none;
    > > font-family: Georgia, "Times New Roman", Times, serif;
    > > color: #FF0000;
    > > }
    > > </style>
    > >
    > > <script>
    > >
    > > function showHideSwitch2 (theid, value) {
    > > if (document.getElementById) {
    > > switch_id = document.getElementById(theid);
    > > if (value == 'show') {
    > > switch_id.className = 'showSwitch';
    > > }else{ switch_id.className = 'hideSwitch';
    > > }
    > > }
    > > }
    > >
    > > </script>
    > >
    > >
    > > <style type="text/css">
    > > <!--
    > > -->
    > > </style>
    > >
    > > </head>
    > > <body background="Images/BG.jpg">
    > > <table width="100%" height="100%" border="0" align="center"
    > > cellpadding="0" cellspacing="0">
    > > <tr>
    > > <td align="center" valign="middle">
    > > <table width="700" height="600" border="1" align="center"
    > > cellpadding="0" cellspacing="0" bordercolor="#B1D3EC">
    > > <tr>
    > > <td bgcolor="#FFFFFF">
    > > <table width="100%" height="100%" border="0"
    > > align="center" cellpadding="0" cellspacing="0">
    > > <tr>
    > > <td><div align="left">&nbsp;&nbsp;&nbsp;&nbsp;<img
    > > src="Images/edit_news.jpg" width="142" height="40"></div></td>
    > > </tr>
    > > <tr>
    > > <td><p align="center">&nbsp;</p>
    > > <p align="left">&nbsp;</p>
    > > <table width="95%" border="0" align="center"
    > > cellpadding="0" cellspacing="0">
    > > <%
    > > While ((Repeat1__numRows <> 0) AND (NOT rs_news_edit.EOF))
    > > %>
    > > <tr>
    > > <td width="28%"><p
    > > align="left"><%=(rs_news_edit.Fields.Item("news_summary").Value)%></p>
    > > <p>&nbsp;</p></td>
    > > <td width="28%"><div align="center">
    > >
    > > <p><%=(rs_news_edit.Fields.Item("news_complete").Value)%></p>
    > > <p>&nbsp;</p>
    > > </div></td>
    > > <td width="28%">&nbsp;</td>
    > > <td width="16%">
    > > <div align="center">
    > > <p align="right"><a
    > > href="edit_news_01.asp?<%= MM_keepURL & MM_joinChar(MM_keepURL) &
    > > "id=" & rs_news_edit.Fields.Item("id").Value %>">Change</a>
    > > </p>
    > > <p>&nbsp; </p>
    > > </div></td>
    > > </tr>
    > > <tr>
    > > <td colspan="4"><p align="left"><a
    > > href="javascript:;" onClick="showHideSwitch2('switch4', 'show')">open
    > > 4</a>
    > > <a href="javascript:;" onClick="showHideSwitch2('switch4',
    > > 'hide')">close 4</a>
    > > <p class="hideSwitch" id="switch4"><table width="75%" border="1"
    > > align="center">
    > > <tr>
    > > <td>1</td>
    > > <td>1</td>
    > > <td>1</td>
    > > </tr>
    > > <tr>
    > > <td>1</td>
    > > <td>1</td>
    > > <td>1</td>
    > > </tr>
    > > <tr>
    > > <td>1</td>
    > > <td>1</td>
    > > <td>1</td>
    > > </tr>
    > > </table></p></p>
    > > </td>
    > > </tr>
    > > <tr>
    > > <td colspan="4"><hr></td>
    > > </tr>
    > > <tr>
    > > <td colspan="4">&nbsp;</td>
    > > </tr>
    > > <%
    > > Repeat1__index=Repeat1__index+1
    > > Repeat1__numRows=Repeat1__numRows-1
    > > rs_news_edit.MoveNext()
    > > Wend
    > > %>
    > > </table>
    > > <p align="center">&nbsp;</p>
    > > <p align="center">&nbsp;</p>
    > > <p align="center">&nbsp;</p>
    > > <p align="center">&nbsp;</p>
    > > <p align="center">&nbsp;</p></td>
    > > </tr>
    > > </table></td>
    > > </tr>
    > > <tr>
    > > <td height="10" bgcolor="#B1D3EC">&nbsp;</td>
    > > </tr>
    > > </table></td>
    > > </tr>
    > > </table>
    > > </body>
    > > </html>
    > > <%
    > > rs_news_edit.Close()
    > > Set rs_news_edit = Nothing
    > > %>
    > >
    > >
    > > =====================================================================
    > >
    > > The problem is that the table with the '1's in it does not appear in
    > > each repeat region bit, so for example if you clicked on the 5th
    > > repeated region section the table would still open in the first
    > > section with the included dynamic data also from the first item
    > >
    > > Is there anyway I can fix this ?
    > >
    > > Thanks in advance,
    > >
    > > Andy.

    >
    > Andy this is VBScript.
    > This post has been copied to microsoft.public.scripting.vbscript, check
    > there for a reply.
    > Follow-ups have been set to microsoft.public.scripting.vbscript only.
    > --
    > Andrew Urquhart
    > - FAQ: http://jibbering.com/faq
    > - Archive: http://groups.google.com/groups?group=comp.lang.javascript
    > - Reply: www.andrewu.co.uk/about/contact/
    >
    >
     
    Andy, Mar 4, 2004
    #2
    1. Advertising

  3. Andy

    kaeli Guest

    In article <404787d5$0$24358$>, andyww14
    @hotmail.com enlightened us with...
    >
    > Hi Andrew,
    >
    > The VBscript is for the ASP code, there is a little JavaScript within
    > section of code that controls the show hide aspect of website, its this I
    > hope to fix.
    >


    Then copy and paste the code as the browser sees it. With View->Source.
    Preferably in a smaller bit of code that simply demonstrates the
    javascript problem so we can copy and paste it and play with it.

    You expect us to know VBScript? ;)
    (actually having the script there is confusing if it is a JS problem,
    because we don't see what the browser sees, so how can we fix it?)

    From what I can tell, though, the name is hardcoded as
    <a href="javascript:;" onClick="showHideSwitch2('switch4', 'hide')">

    Well, if that piece repeats as it shows, the same div will be passed for
    every click. So that same div will be hidden and shown every time.
    Check the real source to see.

    --
    --
    ~kaeli~
    Santa's helpers are subordinate clauses.
    http://www.ipwebdesign.net/wildAtHeart
    http://www.ipwebdesign.net/kaelisSpace
     
    kaeli, Mar 4, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?VGltOjouLg==?=

    DataGrid and JavaScript GURU...

    =?Utf-8?B?VGltOjouLg==?=, Jul 18, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    3,512
    =?Utf-8?B?VGltOjouLg==?=
    Jul 18, 2005
  2. Replies:
    9
    Views:
    541
    CBFalconer
    Apr 25, 2006
  3. joebob
    Replies:
    2
    Views:
    154
    Grant Wagner
    Jun 11, 2004
  4. Jarrod Hyder

    Need a javascript guru (I need help!)

    Jarrod Hyder, Jan 27, 2005, in forum: Javascript
    Replies:
    1
    Views:
    89
  5. Nogiruki

    JavaScript / Web 2.0 guru in NYC

    Nogiruki, Jul 26, 2007, in forum: Javascript
    Replies:
    0
    Views:
    89
    Nogiruki
    Jul 26, 2007
Loading...

Share This Page