Results 1 to 6 of 6

Thread: Hard Q, Printing a hyperlink from a FORM

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Ireland
    Posts
    224

    Question Hard Q, Printing a hyperlink from a FORM

    Hi Guys
    I have a table that contains a form. The table has hyperlinks to other html pages with a input box (checkbox) beside. What I am trying to do, is have a button at the end of the form that will print all the hyperlinks that have been selected using the checkboxes. Here is the code that is generated by my ASP page.
    Code:
    <form name='form2'>
    <table border = 0>
    <tr>
    <td bgcolor='#ffffcc'>
    <a href = '#' onclick = window.open('http://100.100.100.100/Reports/REPORTS_20.htm','javascript_1','height=600,width=700,resizable,scrollbars=yes')>SUMMARY_REPORTS_20010220.htm</a><BR></td>
    <td bgcolor = '#336699'>
    <input type='checkbox' name = 'REPORTS_20.htm' style='HEIGHT: 22px; WIDTH: 99px'></td>
    </tr>
    <tr>
    <td bgcolor='#ffffcc'>
    <a href = '#' onclick = window.open('http://100.100.100.100/Reports/REPORTS_21.htm','javascript_1','height=600,width=700,resizable,scrollbars=yes')>CROSS_CURRENCY_REPORTS_20010220.htm</a><BR>
    </td>
    <td bgcolor = '#336699'><input type='checkbox' name = 'REPORTS_21.htm' style='HEIGHT: 22px; WIDTH: 99px'></td>
    </tr>
    </table>
    </form>
    Here is look at the ASP code that I use to generate this page

    Code:
    Response.write "<form name='form2'>"	 
    Response.write "<table border = 0>"
    Response.write ""
    For Each objFile In objFSO.GetFolder("D:\Web Server\wwwroot\generatedReports\").Files 
    Response.Write "<tr><td bgcolor='#ffffcc'><a href = '#' onclick = window.open('http://100.100.100.100/Reports/" & objFile.name & "','javascript_1','height=600,width=700,resizable,scrollbars=yes')>" & objFile.name &  "</a><BR></td>" 
    Response.write "<td bgcolor = '#336699'><input type='checkbox' name = '" & objFile.name & "' style='HEIGHT: 22px; WIDTH: 99px'></td></tr>"
    Next
    Response.Write "</table>"
    Response.Write "</form>"

    I would really appreciate any help that anyone may be able to offer.
    Cheers
    JK

  2. #2
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    OK.... I had a similar need... here's how I handled it:

    1) I had a hidden field that contained the record's ID

    2)I wrote a small function that toggled the checkbox's value from 0 to the value of the hidden field that was associated with it whenever it was clicked.

    3) When the form is submitted, the only the checkboxes that are selected will be passed, along with the IDs of the records I needed to do something with.

    4)Do your print from the database records using the IDs in the where clause.
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Ireland
    Posts
    224
    Hi monte96
    Thanks for the reply. I'm not really too sure how to do the fisrt part of what your describing.
    I had a hidden field that contained the record's ID
    Can you explain to me how to do this, or show me an example??? Thanks again for the help. I really appreciate it.
    Cheers
    JK

  4. #4
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    I'm assuming good database design in that each table should have a record ID.
    In Access, you would make this an Autonumber and it is essentially your primary key for the database table.
    When you read in the records from the database, put the primary key into a hidden field on the line with the rest of the displayed data.

    For instance:

    Code:
    ...
    <TR>
    <TD>
    <INPUT type="hidden" name=txtID id=txtID value="%=rs.fields("PrimaryKeyFieldName")%>"><INPUT type="Text" name=txtName is=txtName value="<%=rs.fields("UserName")%>">
    </TD>
    <TD>
    <INPUT type="CheckBox" name=chkSelect id=chkSelect value=0>
    </TD>
    </TR>
    ...
    What I then did is figure out where these tags fall in the document.all collection in relation to one another (the checkbox and the hidden field).

    Once you know that, you can set the value of the checkbox to the value of the hidden textbox for each selected checkbox just before the form is submitted.

    On the server side of the receiving page, you have only the checkboxes that were selected with values of the records that they represent.
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

  5. #5
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    I would (and am going to) go about this a bit differently in my website:
    (I implement this so that my links are never broken...)

    Code:
    <%
    '...connect to database, connect to table with Hyperlink, and LinkName fields.
    '...make sure oRec is a valid ADODB.Recordset
    Sub WriteLink(Nme)
       oRec.MoveFirst
       oRec.Find "LinkName = '" + Nme + "'"
       If oRec.EOF and oRec.BOF Then
          Response.Write "#" 'write pound so page doesnt change
       Else
          Response.Write oRec("Hyperlink")
       End If
    End Sub
    %>
    <HTML>
    <HEAD>
    ....
    ....
    <A HREF=<%WriteLink("LoginPage")%>>Login Page</A>
    ....
    ....
    </BODY>
    </HTML>
    ..this is what you want to do right?
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  6. #6
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Whoa.... was I way off or what?

    Sorry about that!
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

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