Flash Games
 FAQ   Search   Memberlist   Usergroups   Register  Profile   Log in to check your private messages   Log in 


html and variables



 

Post new topic   Reply to topic  
   DEVPPL Forum Index -> HTML Forum
View previous topic :: View next topic  
Author Message
boylesg



Joined: 25 Apr 2008
Posts: 5

PostPosted: Mon Apr 28, 2008 2:16 pm    Post subject: html and variables Reply with quote

Don't know whether any one else has thought of this but I will share anyway....

I have a series of tables on different pages containing plant items. All the table cells are identical except for their contents.

Woundn't it be great if you could just define a table of variables containing the values you want to insert into each cell. Then you would just have to edit the variables in one place rather than scrolling through the table code or mucking around in Frontpage or what ever.

Nice idea except you can only use variables as paramaters to calls to javascript functions but you can't use them as paramters to html tags.

However I figured out that the bits of html code, where I wished to use my variables as parameters to html tags I could simply write into the page via java script. Here is an example:

A bit messy but it sure makes creating new pages and changing contents so much easier.

<tr>

<script language="javascript">
document.write("<td align=\"center\"><font face=\"Arial\" size=\"2\"><img border=\"0\" src=" + AWP14Photo + " width=\"210\" height=\"212\"></font></td>");
document.write("<td align=\"center\"><i><font face=\"Arial\" size=\"2\">" + AWP14SpeciesName + "</font></i></td>");
document.write("<td align=\"center\"><font face=\"Arial\" size=\"2\">" + AWP14CommonName + "</font></td>");
document.write("<td align=\"center\"><font size=\"2\" face=\"Arial\">" + AWP14Status + "</font></td>");
document.write("<td align=\"center\"><font face=\"Arial\" size=\"2\">" + AWP14Size + "</font></td>");
document.write("<td align=\"center\"><font face=\"Arial\" size=\"2\">" + '$' + AWP14Price + "</font></td>");
</script>

<td align="center"><font face="Arial" size="2"><input name=addbox type=button value=" Add to cart " onclick=Loc_additem("AWP014",AWP14Price,AWP14Desc,ThisPage)></font>
<p><font face="Arial" size="2">
<input type=button name=subbox value="Subtract from cart" onclick=Loc_subitem("AWP014",AWP14Price,AWP14Desc,ThisPage)></font>
</p>
<p><font face="Arial" size="2">Quantity: <input type=text name=AWP014 size=2></font></p>
<p><font face="Arial" size="2">
<applet code="fphover.class" codebase="./" width="38" height="38">
<param name="textcolor" value="#FFFFFF">
<param name="text" value=" ">
<param name="color" value="#FFFFFF">
<param name="hovercolor" value="#000000">
<param name="effect" value="reverseGlow">
<param name="bgcolor" value="#FFFFFF">
<param name="url" valuetype="ref" value="javascript:parent.updatemain_order()">
<param name="image" valuetype="ref" value="images/cart_go.png">
</applet>
</font></p>
</td>
</tr>
Back to top
View user's profile Send private message Send e-mail
rangana
250+ Club


Joined: 27 Feb 2008
Posts: 271
Location: Cebu City Philippines

PostPosted: Tue Apr 29, 2008 1:18 am    Post subject: Re: html and variables Reply with quote

Document.write is deprecated...you could change it to innerHTML Wink
Back to top
View user's profile Send private message Yahoo Messenger
boylesg



Joined: 25 Apr 2008
Posts: 5

PostPosted: Tue Apr 29, 2008 1:29 am    Post subject: Re: html and variables Reply with quote

rangana wrote:
Document.write is deprecated...you could change it to innerHTML Wink


Why do you say that document.write is inadvisable?
Back to top
View user's profile Send private message Send e-mail
rangana
250+ Club


Joined: 27 Feb 2008
Posts: 271
Location: Cebu City Philippines

PostPosted: Tue Apr 29, 2008 2:32 am    Post subject: Re: html and variables Reply with quote

Being the easiest way to write HTML out from Javascript doesn't mean that it is the best way to write HTML from Javascript or even that it will work in all situations. In fact the document.write method is very limited in what you can do with it.
This links might be of help Wink
http://www.codingforums.com/showpost.php?p=366293&postcount=6
http://developer.apple.com/internet/webcontent/dom2i.html
Back to top
View user's profile Send private message Yahoo Messenger
dflynn
250+ Club


Joined: 03 Oct 2007
Posts: 310
Location: Guelph, Canada

PostPosted: Tue Apr 29, 2008 2:57 am    Post subject: Re: html and variables Reply with quote

I don't get the purpose of this... isn't it essentially just css in a rather confusing manner?
Back to top
View user's profile Send private message MSN Messenger
boylesg



Joined: 25 Apr 2008
Posts: 5

PostPosted: Tue Apr 29, 2008 8:03 am    Post subject: Re: html and variables Reply with quote

dflynn wrote:
I don't get the purpose of this... isn't it essentially just css in a rather confusing manner?

If you add the following to the code above does it help you understand what I was trying to acheive? It means that the create new table rows all I have to copy the last row and past it at the bottom, changing the "AWP1" part of the vairbale names to the next consecutive number and then add those variables at the top of the file along with the rest.

What is CSS by the way?

TubePrice = "3.50"
PotPrice = "9.00"
ThisPage = "AquaticWetlandHerbs.html"

AWP1Desc = "Alisima_plantago-aquatica"
AWP1Photo = "http://i209.photobucket.com/albums/bb196/boylesg/AquaticWetland/plantago-aquatica-1.jpg"
AWP1SpeciesName = "Alisima plantago-aquatica"
AWP1CommonName = "Water Plantain"
AWP1Status = "Local native"
AWP1Size = "Tube"
AWP1Price = TubePrice

AWP2Desc = "Cotula_coronopifolia"
AWP2Photo = "http://i209.photobucket.com/albums/bb196/boylesg/AquaticWetland/coronopifolia-flowers.jpg"
AWP2SpeciesName = "Cotula coronopifolia"
AWP2CommonName = "Creeping Crotula"
AWP2Status = "Local native"
AWP2Size = "Tube"
AWP2Price = TubePrice

AWP3Desc = "Hydrocotyl_verticillata"
AWP3Photo = "http://i209.photobucket.com/albums/bb196/boylesg/AquaticWetland/verticillata.jpg"
AWP3SpeciesName = "Hydrocotyl verticillata"
AWP3CommonName = "Shield Pennywort"
AWP3Status = "Local native"
AWP3Size = "Tube"
AWP3Price = TubePrice

AWP4Desc = "Lobelia_pratiodies"
AWP4Photo = "http://i209.photobucket.com/albums/bb196/boylesg/AquaticWetland/pratioides-plant.jpg"
AWP4SpeciesName = "Lobelia pratiodies"
AWP4CommonName = "Poison Lobelia"
AWP4Status = "Local native"
AWP4Size = "Tube"
AWP4Price = TubePrice
Back to top
View user's profile Send private message Send e-mail
rangana
250+ Club


Joined: 27 Feb 2008
Posts: 271
Location: Cebu City Philippines

PostPosted: Tue Apr 29, 2008 11:01 am    Post subject: Re: html and variables Reply with quote

boylesg wrote:

What is CSS by the way?


CSS lets you control the style and layout of your pages Smile

Give it a google and you'll find better explanation. I'll recommend this:
CSS http://www.w3schools.com/Css/default.asp
Back to top
View user's profile Send private message Yahoo Messenger
boylesg



Joined: 25 Apr 2008
Posts: 5

PostPosted: Tue Apr 29, 2008 11:26 am    Post subject: Re: html and variables Reply with quote

rangana wrote:
boylesg wrote:

What is CSS by the way?


CSS lets you control the style and layout of your pages Smile

Give it a google and you'll find better explanation. I'll recommend this:
CSS http://www.w3schools.com/Css/default.asp

Is it meant to be an alternative to html or a script of sorts like javascript?
Back to top
View user's profile Send private message Send e-mail
dflynn
250+ Club


Joined: 03 Oct 2007
Posts: 310
Location: Guelph, Canada

PostPosted: Tue Apr 29, 2008 11:36 am    Post subject: Re: html and variables Reply with quote

It doesn't replace HTML completely, instead it replaces the parts that clutter HTML coding such as styling the page. so <Font> tags, and styles withing <body> tags etc.

It's not like Javascript, but I guess similar in the sense that it relies on HTML to exist, because without HTML the others are practically useless.
Back to top
View user's profile Send private message MSN Messenger
rangana
250+ Club


Joined: 27 Feb 2008
Posts: 271
Location: Cebu City Philippines

PostPosted: Wed Apr 30, 2008 1:22 am    Post subject: Re: html and variables Reply with quote

CSS is different from HTML and is different from javascripts Wink

If I were to describe, web designing is like a house..HTML is your framework, your house's skeleton.

CSS paints the house, gives color and peculiar beauty Smile

Javascripts is your house's electricity, it powers your house...you could always live without electricity, but when there is one, your house will be lively Wink

Flash is like a big tv in the middle of the house...it adds to the house's liveliness.

Hope makes sense Smile
Back to top
View user's profile Send private message Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    DEVPPL Forum Index -> HTML Forum All times are GMT + 1 Hour
Page 1 of 1

 
 
Welcome to DEVPPL.com
You are not logged in, which means that you can't post in the forums.
Click here to Register

If you are a current member here on DEVPPL, please login below:

User: Pass:
Log me on automatically each visit:

 


Powered by phpBB © 2001, 2005 phpBB Group - Modified by DEVPPL

Flash Games - Sitemap