SitePoint Sponsor

User Tag List

Results 1 to 14 of 14

Thread: Function help

  1. #1
    SitePoint Zealot XzAzX's Avatar
    Join Date
    Apr 2002
    Location
    Holland
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Function help

    well, i have a code which has to enlarge a message when clicked.

    Code:
    <SCRIPT>
    
    		function NeHandler(nyhet)
            {
            
                    if(document.getElementById(nyhet).style.display=="none")
                    {
                        document.getElementById(nyhet).style.display=''  ;
                       
                    }
                    else
                    {
                        document.getElementById(nyhet).style.display="none";
                        
                    }
            }
    </SCRIPT>
    <table border="0" width="100%" cellspacing="0" cellpadding="3">
                        
              <tr>
    		  <!-- begin news 1 -->
               <td width="100%" bgcolor="#A996CF" colspan="2" style="cursor=hand" 
    onClick="javascript:NeHandler('nyhet')">
     			          &nbsp;<b><?=$news_topic?> </b> ( 2003-01-21 )
     			           
    
               </td>
              </tr>
              <TR>
    		  
    		  <!-- begin inhoud news 1 -->
              	<td bgcolor="#A996CF" style="display:none" id="<?=$post_id?>">
                    	<BLOCKQUOTE>
                    	
                    	<TABLE border="0" cell
    spacing="0" cellpadding="0" width="438" BORDERCOLOR="#000000" style="border-collapse:collapse">
        <tr> 
          <td valign="top" class="maintitle-left" border="0"></td>
    
          <td valign="top" class="maintitle-mid" border="0">
    	  <font color="white">
    	   Posted by <b><?=$author?></b> on <b><?=$date?></b> 
    	   <span align="right">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Subject : <b> 
            <?=$news_topic?>        </b>
    		</span>
    	  
    	  </td>
    	
          <td valign="top" class="maintitle-right" border="0"></td>
        </tr>
    	 </table>
       <TABLE border="1" cell
    spacing="0" cellpadding="0" width="438" BORDERCOLOR="#000000" style="border-collapse:collapse">
        <tr> 
          <td align="center"  colspan="3"> 
                 <br><br>
    			 <?=$news?>
    			 <br><br>
         
          </td>
        </tr>
    	 </table>
    Ok, the JS has to work with PHP in this code.
    It has to open the nyhet where the id = <?=$post_id?>

    but how to do this in this line ?

    Code:
     onClick="javascript:NeHandler('nyhet')">


    this:

    onClick="javascript:NeHandler('nyhet_<?=$post_id?>')">

    doesn't work..

    Any help from a JS pro plz?
    if something is unclear, plz ask..

    (http://members.lycos.nl/eggforum/test/1.html this is how its supposed to work, but this is without the PHP)

    plz help me !
    THX!
    Last edited by XzAzX; Jan 22, 2003 at 05:17.
    _o_ OOP _o_

  2. #2
    Feel my RewiredMind KMxRetro's Avatar
    Join Date
    Jan 2001
    Location
    Exeter, Devon, UK
    Posts
    477
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In the PHP page, echo the Javascript out to the page, like this...

    PHP Code:
    <!-- begin news 1 -->

    <? 
    echo '<td width="100%" bgcolor="#A996CF" colspan="2" style="cursor=hand" 
    onClick="javascript:NeHandler('
    nyhet_$post_id')">';
    ?>

    <b><?=$news_topic?>
    I've only just woken up, so apologies for the bad quote marks and possibly invalid variable reference

    That's the basic method though...output the whole line of Javascript through PHP.

    Hope this helps,

  3. #3
    SitePoint Zealot XzAzX's Avatar
    Join Date
    Apr 2002
    Location
    Holland
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i'll try it the next free hour i have on school

    thx m8 !
    _o_ OOP _o_

  4. #4
    SitePoint Zealot XzAzX's Avatar
    Join Date
    Apr 2002
    Location
    Holland
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ..

    I doesnt see the $post_id
    cause when i edit it in explorer :

    Code:
    <td width=100% bgcolor=#A996CF colspan=2 style=cursor:hand onClick=javascript:NeHandler('nyhet_')>
    http://members.lycos.nl/eggforum/test/2.php

    ...
    Last edited by XzAzX; Jan 22, 2003 at 06:38.
    _o_ OOP _o_

  5. #5
    Feel my RewiredMind KMxRetro's Avatar
    Join Date
    Jan 2001
    Location
    Exeter, Devon, UK
    Posts
    477
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, try this....

    PHP Code:
    <? 
    echo "<td width=100% bgcolor=#A996CF colspan=2 style='cursor=hand' 
    onClick=\"javascript:NeHandler('nyhet_"
    .$post_id."')\">";
    ?>

  6. #6
    SitePoint Zealot XzAzX's Avatar
    Join Date
    Apr 2002
    Location
    Holland
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it works thx m8!
    _o_ OOP _o_

  7. #7
    Feel my RewiredMind KMxRetro's Avatar
    Join Date
    Jan 2001
    Location
    Exeter, Devon, UK
    Posts
    477
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No problem man. Glad it works.

    Cheers,

  8. #8
    SitePoint Zealot XzAzX's Avatar
    Join Date
    Apr 2002
    Location
    Holland
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    _o_ OOP _o_

  9. #9
    Feel my RewiredMind KMxRetro's Avatar
    Join Date
    Jan 2001
    Location
    Exeter, Devon, UK
    Posts
    477
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Very nice, XzAzX.

    Popping up the news like that is a good idea and it certainly seems to work well.

    Good job!

  10. #10
    SitePoint Zealot XzAzX's Avatar
    Join Date
    Apr 2002
    Location
    Holland
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thx to u
    _o_ OOP _o_

  11. #11
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    FWIW, XzAzX, I like the site, and think you should implement mod_rewrite (if your host has it) I just finished applying it for the first time to my site and I love it. The web-geek in me loves the pretty URLs. The professional in me loves the search-engine friendliness of them.

    Anyhoo, if you'd like to, I'll help ya.
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  12. #12
    SitePoint Zealot XzAzX's Avatar
    Join Date
    Apr 2002
    Location
    Holland
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by beetle
    FWIW, XzAzX, I like the site, and think you should implement mod_rewrite (if your host has it) I just finished applying it for the first time to my site and I love it. The web-geek in me loves the pretty URLs. The professional in me loves the search-engine friendliness of them.

    Anyhoo, if you'd like to, I'll help ya.
    whats mod_rewrite
    _o_ OOP _o_

  13. #13
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    mod_rewrite is a module for Apache webserver that will "rewrite" and incoming URL to something else, based on a regular expression pattern. For example, on my site

    www.peterbailey.net/site/services/

    is rewritten to

    www.peterbailey.net/site.php?page=services

    The rewrite rule is placed in your .htaccess file and looks like this (well, for the rewrite above)

    RewriteRule ^site/([^/]+)/?$ /site.php?page=$1 [L]

    If you're familiar with regular expressions, this should make sense to you, for the most part.
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  14. #14
    SitePoint Zealot XzAzX's Avatar
    Join Date
    Apr 2002
    Location
    Holland
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    uhm...no
    _o_ OOP _o_


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
  •