SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Thread: td Link

  1. #1
    SitePoint Member
    Join Date
    Mar 2002
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question td Link

    This is probably a really simple question, but how do I make a cell link to another page when a user clicks the cell?

    I tried the following, but it only worked when I clicked on the text itself:

    <a href="link.html"><td>blah blah blah</td></a>

  2. #2
    SitePoint Addict
    Join Date
    Apr 2001
    Location
    None
    Posts
    254
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can't... it's impossible

  3. #3
    That's Right. notepad_coder's Avatar
    Join Date
    Apr 2002
    Location
    Colorado
    Posts
    835
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think this should work.
    PHP Code:
    <script language="JavaScript">
      function 
    changePage(pageName) {
        
    window.location.href pageName;
      }
    </script> 
    and then for the link.
    PHP Code:
    <td onMouseOver="this.style.cursor='hand';" onClick="changePage('nextpage.html');"
    the onMouseOver event is there to make it look like a link, if you dont want it there you can just take it out.
    Last edited by notepad_coder; Apr 8, 2002 at 12:02.

  4. #4
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:

    <html
    <
    head
    <
    title>submitting types</title

    <
    script language="javascript">

    function 
    c(color)
    {
        var 
    c    =    new Array;

        
    // if using hex include #

        
    c[0]    =    'black';
        
    c[1]    =    'white';
        
    c[2]    =    '#606D79';
        
    c[3]    =    '#D0D6DF';
        
    c[4]    =    '#BEC7D3';
        
    c[5]    =    '#A0A8C0';
        

        if (
    color>c.length || color<|| color == nullalert('number less than\nnumber greater than\nor null');
        
        
    //keep adding in the following format and remember if using hex remember the #

        
    return c[color];
    }

    '<style type=\"text/css\">';
    s+= '<!--';
    s+= 'a:hover     {  color: ' c(1) + '; background-color: ' c(0) + ';}';
    s+= 'a:active     {  color: ' c(0) + '; background-color: ' c(1) + ';}';
    s+= 'a:link     {  color: ' c(0) + '; background-color: ' c(1) + ';}';
    s+= 'a:visited     {  color: ' c(0) + '; background-color: ' c(1) + ';}';
    s+= '}';
    s+= '-->';
    s+= '</style>';


    document.write (s);
     
    function 
    submitform()
    {
        
    with (document.form1)
        {




            if (
    document.input.action.value =='http://' || document.input.action.value =='')
            {
                
    action     '';
            }
            else
            {
                
    action     document.input.action.value;
            }


            if (
    document.input.enctype.value =='')
            {
                
    enctype 'application/x-www-form-urlencoded';
            }
            else
            {
                
    enctype document.input.enctype.value;
            }
        
        
    target     document.input.target.value;
        
            
    submit(); 
        }


    </script> 
    </head> 

    <body bgcolor="#FFFFFF" text="#000000">
    <center> 
        <table border=1>
        <td>
        <form name="input">
          <p>
            
             <br>url        <input type="text"  name="action"  value="http://" size=50><br>
             <br>method        <input type="radio" name="method"  value="post" onclick="document.form1.method=this.value" checked>    post
                         <input type="radio" name="method"  value="get"  onclick="document.form1.method=this.value">        get<br>
             <br>enctype    <input type="text"  name="enctype" value="application/x-www-form-urlencoded" size=50><br>
             <br>target        <input type="text"  name="target"  value="_self" size=50><br>
          </p>
        </form>

          
        <td onMouseOver="this.style.cursor='hand';" onClick="submitform()" bgcolor="black">    
        <form name="form1">
          <center>
            <input type="text" name="name" value="Variable_to_be_passed"><br>
            <a href="javascript:submitform();">click here</a>
            <script>document.form1.name.size = document.form1.name.value.length + 1</script>
          </center>
        </form> 
        </td>
          </tr>
        <table>
    </center>
    </body> 
    </html> 
    lol try this one out

  5. #5
    That's Right. notepad_coder's Avatar
    Join Date
    Apr 2002
    Location
    Colorado
    Posts
    835
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The last post wont work for me, and it's kinda complicated.

  6. #6
    pg for mild peril cow's Avatar
    Join Date
    Mar 2000
    Location
    nevada, usa
    Posts
    636
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this should work:

    Code:
    <td onMouseOver="this.style.cursor='hand';" onClick="window.location.href='link.htm'">td content...</td>
    just replace link.htm with the page you want to link to.
    "There's no justice like angry mob justice!" --Seymour Skinner

  7. #7
    SitePoint Member
    Join Date
    Mar 2002
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your help everyone! You're awesome!


Bookmarks

Posting Permissions

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