SitePoint Sponsor |
|
User Tag List
Results 1 to 24 of 24
Thread: isert java into a cell of table
-
Oct 16, 2002, 13:36 #1
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 ???????????
-
Oct 16, 2002, 18:38 #2
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.
-
Oct 17, 2002, 00:54 #3
- 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%> </td> <td id=td2 width=33%> </td> <td id=td3 width=33%> </td> </tr> <tr> <td id=td4 width=33%> </td> <td id=td5 width=33%> </td> <td id=td6 width=33%> </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
-
Oct 17, 2002, 02:18 #4
nice
thax geoflux
very nice idea spartan i ll try 2 do it
-
Oct 17, 2002, 02:42 #5
- 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
-
Oct 17, 2002, 02:47 #6
u mean................
do u mean i must take care of my statements and write
Code:<h3>ahmed</h3> <br>
Code:<ahmed>
-
Oct 17, 2002, 02:58 #7
- 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"
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>"
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
-
Oct 17, 2002, 03:09 #8
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 ????????
-
Oct 17, 2002, 03:19 #9
- 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
-
Oct 17, 2002, 03:30 #10
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> </td> </tr> <tr> <td> </td> <td> </td> </tr>
-
Oct 17, 2002, 03:40 #11
- 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>
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
-
Oct 17, 2002, 03:47 #12
both
i wanna keep both
"here i mean"
and
"some thing else"
can i ????????
-
Oct 17, 2002, 04:02 #13
- 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
-
Oct 17, 2002, 04:06 #14
thank u
thank u very much
-
Oct 17, 2002, 04:09 #15
- 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
-
Oct 17, 2002, 06:43 #16
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 negativityhttp://www.geoflux.com
embrace the pace of a new world.
-
Oct 17, 2002, 06:49 #17
- 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 suxSpartan
---------------------
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
-
Oct 17, 2002, 06:51 #18
-
Oct 17, 2002, 06:57 #19
- 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
-
Oct 17, 2002, 07:12 #20Code:
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()">
-
Oct 17, 2002, 09:20 #21
"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.
-
Oct 17, 2002, 23:21 #22
- 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
-
Oct 19, 2002, 20:09 #23
- Join Date
- Jul 2002
- Posts
- 168
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You should check this out: DOM Compliant "innerHTML" / "innerText" for Netscape 6
-
Oct 19, 2002, 20:49 #24
- 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?
2. innerHTML, not innerHtml (case sensitive...)
Bookmarks