Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 08-09-2003, 05:12 PM   #1 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,470
sde is on a distinguished road
javascript question

Code:
<script>
var i = 1;
document.write(i);
</script>
is there a way for later down the html page for me to change i above? for example .. after that script showed up .. this one did.
Code:
<script>
i = 2;
</script>
please say yes!
__________________
Mike
sde is online now   Reply With Quote
Old 08-09-2003, 05:28 PM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,470
sde is on a distinguished road
Code:
<span id=message>Hello</span>

<script>
document.getElementById('message').innerText='Goodbye';
</script>
this works .. but could it be done outside a span tag?

what i want to do is make a progress bar with a table % in html.

Code:
<table bgcolor=blue width=<script>// print var here</script>%>&nbsp;</table>
__________________
Mike
sde is online now   Reply With Quote
Old 08-09-2003, 05:37 PM   #3 (permalink)
Admin
$_['Your_Mom'];
 
Admin's Avatar
 
Join Date: May 2002
Location: Santee
Posts: 627
Admin is on a distinguished road
javascript is the devil.
guinness is good.
__________________


Urban Clothing
Admin is offline   Reply With Quote
Old 08-09-2003, 10:11 PM   #4 (permalink)
npa
Code Monkey
 
Join Date: Jul 2003
Location: canada
Posts: 82
npa is on a distinguished road
Re: javascript question

Quote:
Originally posted by sde


please say yes!
did you even try that code? it should work.
__________________
direct entry file specification.
npa is offline   Reply With Quote
Old 08-10-2003, 06:27 AM   #5 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,470
sde is on a distinguished road
of course i tried it .. it did not work.

i was making a php/javascript progress bar .. so you could show progress on the client even while something server-side was processing =)

i did something like this:

Code:
<table border=0 cellspacing=1 cellpadding=0 width=600 heigth=20>
<tr>
  <td id=progress1 width=10% bgcolor=#cccccc>&nbsp;</td>
  <td id=progress2 width=10% bgcolor=#cccccc>&nbsp;</td>
  <td id=progress3 width=10% bgcolor=#cccccc>&nbsp;</td>
  <td id=progress4 width=10% bgcolor=#cccccc>&nbsp;</td>
  <td id=progress5 width=10% bgcolor=#cccccc>&nbsp;</td>
  <td id=progress6 width=10% bgcolor=#cccccc>&nbsp;</td>
  <td id=progress7 width=10% bgcolor=#cccccc>&nbsp;</td>
  <td id=progress8 width=10% bgcolor=#cccccc>&nbsp;</td>
  <td id=progress9 width=10% bgcolor=#cccccc>&nbsp;</td>
  <td id=progress10 width=10% bgcolor=#cccccc>&nbsp;</td>
</tr>
</table>


<script>document.getById('progress1').bgColor='navy';</script>
<script>document.getById('progress2').bgColor='navy';</script>
<script>document.getById('progress3').bgColor='navy';</script>
<script>document.getById('progress4').bgColor='navy';</script>
<script>document.getById('progress5').bgColor='navy';</script>
<script>document.getById('progress6').bgColor='navy';</script>
<script>document.getById('progress7').bgColor='navy';</script>
<script>document.getById('progress8').bgColor='navy';</script>
<script>document.getById('progress9').bgColor='navy';</script>
<script>document.getById('progress10').bgColor='navy';</script>
i would still like to get the number in the table width to dynamically increment, .. but i could only get this to work within a class . like span, div, or a table cell.
__________________
Mike
sde is online now   Reply With Quote
Old 08-10-2003, 02:34 PM   #6 (permalink)
npa
Code Monkey
 
Join Date: Jul 2003
Location: canada
Posts: 82
npa is on a distinguished road
Quote:
Originally posted by sde
of course i tried it .. it did not work..
this works for me:
Code:
<html>
	<body>
	<script language="javascript">
		var k = 90;
		alert(k);
	</script>
	
	
	<script language="javascript">
		k++;
		alert(k);
	</script>
	</body>
</html>
__________________
direct entry file specification.
npa is offline   Reply With Quote
Old 08-11-2003, 02:13 AM   #7 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,470
sde is on a distinguished road
i was trying to make it change the width of an html table.
Code:
<script>
int i = 0;
</script>

<table border=1 cellspacing=0 cellpadding=0 width=<script>document.write(i);</script>% bgcolor=blue>
<tr><td>&nbsp;</td></tr>
</table>

<script>i=10;</script>
<script>i=20;</script>
<script>i=30;</script>
.. each time the new variable is defined, i want to update the width of the table.

the new variables have to be defined in a new script like that because i'm flushing the info from the server side as the script processes.

i could not get that to work.
__________________
Mike
sde is online now   Reply With Quote
Old 08-11-2003, 02:21 AM   #8 (permalink)
npa
Code Monkey
 
Join Date: Jul 2003
Location: canada
Posts: 82
npa is on a distinguished road
Quote:
Originally posted by sde
i could not get that to work.
yes, well thats no surprise...

Code:
<table border=1 cellspacing=0 cellpadding=0 width=<script>document.write(i);</script>% bgcolor=blue>
is not valid

try:
Code:
<table id="table1" border="1" othercrap="etc" width="10%">
</table>

<script language="javascript">
table1.width = "500%";
</script>
but it is not clear what you are trying to achieve.

i suggest you read: http://www.w3schools.com tutorials
on javascript before you do any more
__________________
direct entry file specification.
npa is offline   Reply With Quote
Old 08-11-2003, 02:26 AM   #9 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,470
sde is on a distinguished road
i'm trying to make a progress bar which reflects the progress of a server-side script.

for example .. if i am uploading 20 pictures .. normally, the user would have no idea where the progress is until the php page finally finishes ..

but .. if i flush a new <script> and define the new progress, .. after each picture loads, then i can use javascript to show the user how far along they are. =)

server/client-side progress bar lol

www.codenewbie.com/test.php

here is my first script .. now i'm going to try your method .. it would allow me to be much more precice =)

thanks!
__________________
Mike
sde is online now   Reply With Quote
Old 08-11-2003, 02:33 AM   #10 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,470
sde is on a distinguished road
that works great, .. i thank you much =)

it will be nice when it increments by 1%, .. but the script above is just sleeping for 1 second before it flushes the next variable ..so i'll work on something to better demonstrate it when it's not 3:30am.
__________________
Mike
sde is online now   Reply With Quote
Old 08-11-2003, 02:36 AM   #11 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,470
sde is on a distinguished road
but doh! the second method doesn't work in mozilla =/ .. lol, there had to be a catch!
__________________
Mike
sde is online now   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
javascript alert without refreshing? sde HTML, XML, Javascript, AJAX 2 06-30-2004 11:52 AM
DB Design Question Part II sde Program Design and Methods 3 05-10-2003 12:24 PM
Javascript Function jcramer83 HTML, XML, Javascript, AJAX 5 04-14-2003 06:12 AM


All times are GMT -8. The time now is 10:54 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting