How To Replace A Code With A Word In HTML.

ashwinsinha

New Member
Messages
278
Reaction score
0
Points
0
My Problem Is Quite Simple & i Believe There Must Be A Way To Solve It !
What I Want To Do Is That I Actually Want To Replace A Code In My Page With A word Or Another Code.
For Example,
In My Template,
I want to give the link to a page as
HTML:
Play (game) <a href="http://www.mydomain.com/(game).html">
Where In Maybe The Head Tag,
If I Give The Value
HTML:
<head><meta name=(game) value=hawx>
The Code In My Page Is Converted To :
HTML:
Play hawx <a href="http://www.mydomain.com/hawx.html">
& (game) in the whole page is converted to (hawx) while the page is displayed & also in the back end when the link is clicked.

Thanking You,
- Ashwin
 

Scoochi2

New Member
Messages
185
Reaction score
0
Points
0
This is not possible using pure HTML. You need to use a programming language to do this. A quick to implement change would be to add a simple JavaScript function that will change all instances of (game) to hawx (or anything else you want it to). But this means that it will only work on browsers that have JS, and have it enabled.

A better way would be to use server side scripting such as PHP. You could specify a value for a variable, and just include that wherever you want the dynamic link or text to be. This will mean that not only will it work for all browsers, but it will do it more seamlessly as well.
 

freecrm

New Member
Messages
629
Reaction score
0
Points
0
This is not possible using pure HTML. You need to use a programming language to do this. A quick to implement change would be to add a simple JavaScript function that will change all instances of (game) to hawx (or anything else you want it to). But this means that it will only work on browsers that have JS, and have it enabled.

A better way would be to use server side scripting such as PHP. You could specify a value for a variable, and just include that wherever you want the dynamic link or text to be. This will mean that not only will it work for all browsers, but it will do it more seamlessly as well.

try

<?php $new_variable = str_replace("<<<what you want changing>>>", "to whatever you want it changed to", $previous_variable);?>
 
Top