SitePoint Sponsor

User Tag List

Results 1 to 24 of 24

Hybrid View

  1. #1
    SitePoint Addict AHMED's Avatar
    Join Date
    Oct 2002
    Location
    Egypt
    Posts
    399
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    isert java into a cell of table

    hi all
    i have a java script i wanna insert its result into a cell of a table

    the script here
    http://www.dhtmlcentral.com/script/script.asp?id=32

    can any body help me ???????????

  2. #2
    SitePoint Member geoflux's Avatar
    Join Date
    Oct 2002
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You cannot insert copy inside a table cell on the client side with javascript. The only way of doing this would be to either use an textbox and edit its value with javascript, use a layer, or do it using server-side programming.
    http://www.geoflux.com
    embrace the pace of a new world.

  3. #3
    Rehab is for quiters! spartan's Avatar
    Join Date
    Apr 2002
    Location
    Cape Town, South Africa
    Posts
    343
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    WHOAAAOOW their Geoflux... never say "cannot"


    I dont quite know what the script from dhtmlcentral has to do with this, but you can definitely put stuff into a table cell on the client side using javascript.

    I wipped up something small to illistrate my point... what you put inside the cell is really up to you, but it could realy be just about anything...



    Code:
    <HTML>
    <HEAD>
    <TITLE></TITLE>
    <script language=javascript>
    function myfunction(){
    	/*****************************************************
    	 * this is my function and it does stuff and puts the 
    	 * results into table cells
    	 *
    	 ****************************************************/
    	for(I=1;I<7;I++){
    		Cellname = "td" + I
    		thisCell = document.getElementById(Cellname)
    		thisCell.innerText = I
    	}
    
    }
    </script>
    </HEAD>
    <BODY  style="top:0">
    <table width=300 height=300 border=1>
    <tr>
    	<td id=td1 width=33%>&nbsp;</td>
    	<td id=td2 width=33%>&nbsp;</td>
    	<td id=td3 width=33%>&nbsp;</td>
    </tr>
    <tr>
    	<td id=td4 width=33%>&nbsp;</td>
    	<td id=td5 width=33%>&nbsp;</td>
    	<td id=td6 width=33%>&nbsp;</td>
    </tr>
    <tr>
    	<td colspan=3 align=center><input type=button value=clickme onclick="javacript:myfunction()"></td>
    </tr>
    </table>
    </BODY>
    </HTML>

    anybody see that Beetle around cause if I click submit post and find that Beetle beat me to it again... well, lets just say, we dont want that to happen...
    Spartan
    ---------------------
    It's like our sergeant told us before one trip into the jungle. Men! Fifty of you are leaving on a mission. Twenty-five of you ain't coming back.
    -Mr.Payne

  4. #4
    SitePoint Addict AHMED's Avatar
    Join Date
    Oct 2002
    Location
    Egypt
    Posts
    399
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    nice

    thax geoflux
    very nice idea spartan i ll try 2 do it

  5. #5
    Rehab is for quiters! spartan's Avatar
    Join Date
    Apr 2002
    Location
    Cape Town, South Africa
    Posts
    343
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    AHMED

    remember that you may want to put HTML code into the cell, in which case you would need to refer to the innerHtml property and not the .innerText.

    enjoy
    Spartan
    ---------------------
    It's like our sergeant told us before one trip into the jungle. Men! Fifty of you are leaving on a mission. Twenty-five of you ain't coming back.
    -Mr.Payne

  6. #6
    SitePoint Addict AHMED's Avatar
    Join Date
    Oct 2002
    Location
    Egypt
    Posts
    399
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    u mean................

    do u mean i must take care of my statements and write
    Code:
    <h3>ahmed</h3>
    <br>
    and not
    Code:
    <ahmed>
    ?????????

  7. #7
    Rehab is for quiters! spartan's Avatar
    Join Date
    Apr 2002
    Location
    Cape Town, South Africa
    Posts
    343
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    umm...uhh, well...

    ok, lets take the piece of code I posted earlier, right.
    now lets say I was looking to write the line "Ahmed" into the cell. then I would say...
    Code:
    thisCell.innerText = "AHMED"
    ...BUT...

    what If I wanted to put something a little more complex into the table cell, like, another table maybe, or a div, or just format the text with some HTML, well, then you would do it like this instead...

    Code:
    thisCell.innerHtml = "<table><tr><td align=right>AHMED</td></tr><td align=left><b>this is my name</b></td></tr></table>"
    see what I'm saying?

    it just allows you to put html code into the cell instead of just flat text...

    play around with that script I posted earlier a bit... change the stuff thats being displayed in the cell, put some html in or whatever.

    I think you will find that you can do pretty interesting things with the innerHtml property.
    Spartan
    ---------------------
    It's like our sergeant told us before one trip into the jungle. Men! Fifty of you are leaving on a mission. Twenty-five of you ain't coming back.
    -Mr.Payne

  8. #8
    SitePoint Addict AHMED's Avatar
    Join Date
    Oct 2002
    Location
    Egypt
    Posts
    399
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    yes i got it

    ya i got it
    thank u very much
    i thing left
    can i add another html code through the cell it self without no conflict with code i inserted from the java script
    or not ????????

  9. #9
    Rehab is for quiters! spartan's Avatar
    Join Date
    Apr 2002
    Location
    Cape Town, South Africa
    Posts
    343
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    dont quite understand what you're asking.
    but anything you put inside the cell should be valid html...

    if you put junk html in there, it's not going to look or behave you want it to.

    so as long as the stuff you're putting in their is valid code, then you should be fine.

    remember... if you say cell.innerHtml = "whatever"

    then whatever was in the cell would be lost and it would be reset to "whatever"

    so if you want to preserve what is in that cell, but add something on to that, then you should do it like this..

    cell.innerHtml = cell.innerHtml + " and some more stuff to go with whatever was in there already"

    so then you cell would contain a string like this

    "whatever and some more stuff to go with whatever was in their already"
    Spartan
    ---------------------
    It's like our sergeant told us before one trip into the jungle. Men! Fifty of you are leaving on a mission. Twenty-five of you ain't coming back.
    -Mr.Payne

  10. #10
    SitePoint Addict AHMED's Avatar
    Join Date
    Oct 2002
    Location
    Egypt
    Posts
    399
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    i understand u

    my last quis means :
    this string u told me about putting html code into the cell through java script
    and it mean :
    beside this code which i added with js can i add another stuff 2 the cell but through the sequance of the main html code with out conflict
    i mean here
    Code:
     <tr>
        <td> here i mean </td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>

  11. #11
    Rehab is for quiters! spartan's Avatar
    Join Date
    Apr 2002
    Location
    Cape Town, South Africa
    Posts
    343
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no
    you need to replace it all with the new stuff you want added.

    unless you give the table you added first time around a id as well and then reference that... umm.... never tried it before, but it should work.

    if you add code like this to you innitial table cell, the first time around...
    Code:
     <tr>
    <td id=newTD>here I mean</td>
    <td></td>
    </tr>
    <tr>
    <td></td>
    <td></td>
    </tr>
    then you should be able to change the "here I mean" to "something else"

    by doing the same thing you did to the main table...

    document.getElementById("newTD").innerText = "something else"

    is that what you wanted to know?
    or am I still not getting is?
    Spartan
    ---------------------
    It's like our sergeant told us before one trip into the jungle. Men! Fifty of you are leaving on a mission. Twenty-five of you ain't coming back.
    -Mr.Payne

  12. #12
    SitePoint Addict AHMED's Avatar
    Join Date
    Oct 2002
    Location
    Egypt
    Posts
    399
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    both

    i wanna keep both
    "here i mean"
    and
    "some thing else"
    can i ????????

  13. #13
    Rehab is for quiters! spartan's Avatar
    Join Date
    Apr 2002
    Location
    Cape Town, South Africa
    Posts
    343
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yip
    thats what i was saying earlier..

    if you want to add something without losing the existing data.

    cell.innerHtml = cell.innerHtml + "the new stuff"
    Spartan
    ---------------------
    It's like our sergeant told us before one trip into the jungle. Men! Fifty of you are leaving on a mission. Twenty-five of you ain't coming back.
    -Mr.Payne

  14. #14
    SitePoint Addict AHMED's Avatar
    Join Date
    Oct 2002
    Location
    Egypt
    Posts
    399
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cool thank u

    thank u very much

  15. #15
    Rehab is for quiters! spartan's Avatar
    Join Date
    Apr 2002
    Location
    Cape Town, South Africa
    Posts
    343
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no probs
    Spartan
    ---------------------
    It's like our sergeant told us before one trip into the jungle. Men! Fifty of you are leaving on a mission. Twenty-five of you ain't coming back.
    -Mr.Payne

  16. #16
    SitePoint Member geoflux's Avatar
    Join Date
    Oct 2002
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    alright guys. Although this will work in explorer, it is not gonna work in netscape, so it is not cross-browser compatible....that's what i meant If you don't need it to be compatible with netscape, and only need it to work with explorer, then

    p.s. -sorry for the negativity
    http://www.geoflux.com
    embrace the pace of a new world.

  17. #17
    Rehab is for quiters! spartan's Avatar
    Join Date
    Apr 2002
    Location
    Cape Town, South Africa
    Posts
    343
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanx geoflux.
    didn't know that.


    you sayin theres NO way of achieving the same thing on a netscape browser?

    that sux
    Spartan
    ---------------------
    It's like our sergeant told us before one trip into the jungle. Men! Fifty of you are leaving on a mission. Twenty-five of you ain't coming back.
    -Mr.Payne

  18. #18
    SitePoint Addict AHMED's Avatar
    Join Date
    Oct 2002
    Location
    Egypt
    Posts
    399
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking

    me 2

  19. #19
    Rehab is for quiters! spartan's Avatar
    Join Date
    Apr 2002
    Location
    Cape Town, South Africa
    Posts
    343
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    geoflux just spoiled my day
    Spartan
    ---------------------
    It's like our sergeant told us before one trip into the jungle. Men! Fifty of you are leaving on a mission. Twenty-five of you ain't coming back.
    -Mr.Payne

  20. #20
    SitePoint Addict AHMED's Avatar
    Join Date
    Oct 2002
    Location
    Egypt
    Posts
    399
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Red face

    Code:
    function what_custemor_wanna()
                                  if(ur custemor uses IE)
                                     {
                                      while (they can c ur work)
                                       {  
                                         do it 
                                        }
                                       else {
                                             serch 4 another cross-browses script
                                              }
                                          }
                                       }
    
    <body OnWORK="function what_custemor_wanna()">

  21. #21
    SitePoint Member geoflux's Avatar
    Join Date
    Oct 2002
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    "As far as I know" (just to not say "cannot" for spartan ) there is no way of achieving this in netscape. I know that in previous versions of netscape it was not possible, but I haven't really tried with the 7.0 version though.

    Good luck. I didn't mean to spoil your day.
    http://www.geoflux.com
    embrace the pace of a new world.

  22. #22
    Rehab is for quiters! spartan's Avatar
    Join Date
    Apr 2002
    Location
    Cape Town, South Africa
    Posts
    343
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    cool
    thanx for the info GeoFlux.
    Spartan
    ---------------------
    It's like our sergeant told us before one trip into the jungle. Men! Fifty of you are leaving on a mission. Twenty-five of you ain't coming back.
    -Mr.Payne

  23. #23
    SitePoint Zealot
    Join Date
    Jul 2002
    Posts
    168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  24. #24
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by spartan
    ...you sayin theres NO way of achieving the same thing on a netscape browser?
    1. Works in NS6, and Mozilla
    2. innerHTML, not innerHtml (case sensitive...)


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
  •