473,387 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Replace markup with real code

Hi, what I am trying to do is the following, its causing some probs though:

I have the following in a database:
[[imagediv 100.jpg This is the description text]]
This is just some dummy text. It doesn't mean anything and is for
placeholding use only.

And want to change it to:
<div class="imagediv"><img src="/images/100.jpg" alt="100.jpg" width="200"
height="200" /><br />
This is the description text</div>
This is just some dummy text. It doesn't mean anything and is for
placeholding use only.

In the future I might want to use different codes ie [[imagediv 100.jpg This
is the description text]] to reference a different DIV.

Any ideas?
Jul 22 '05 #1
6 1349
Can't say that I follow. What's in the database now? The entire literal
string from "[[imagediv..." to "placeholding use only."? All in one column?
What is the purpose of this data? What are you trying to acheive here?

Ray at work

"bateman" <ba********@nospam.hotmail.com> wrote in message
news:OK**************@TK2MSFTNGP10.phx.gbl...
Hi, what I am trying to do is the following, its causing some probs
though:

I have the following in a database:
[[imagediv 100.jpg This is the description text]]
This is just some dummy text. It doesn't mean anything and is for
placeholding use only.

And want to change it to:
<div class="imagediv"><img src="/images/100.jpg" alt="100.jpg" width="200"
height="200" /><br />
This is the description text</div>
This is just some dummy text. It doesn't mean anything and is for
placeholding use only.

In the future I might want to use different codes ie [[imagediv 100.jpg
This is the description text]] to reference a different DIV.

Any ideas?

Jul 22 '05 #2
Hi, sorry about that.
Yeah if I return the field from the database I get:

[[imagediv 100.jpg This is the description text]]
This is just some dummy text. It doesn't mean anything and is for
placeholding use only.

The reason for this is that I am trying to write a system for a user to
easily add a article, the bits in [[ ]] will be created by buttons they
press making it hopefully pretty much foolproof. I don't trust them with
real code!

There could be multiple instances of this in the field so what I was hoping
I could do was something like this (written in non-code code!)

Take the returned field
Go through it
if you find [[ take out the text between [[ and ]]
split into 3 parts, the first word (imagediv in this case), the picture name
(100.jpg) and the description text (This is the description text)
Then replace the [[ ...... ]] with
<div class="imagediv"><img src="/images/100.jpg" alt="100.jpg" width="200"
height="200" /><br />This is the description text</div>

Then I can use the modified string in my code, hopefully showing the picture
without ever having to explain what a DIV is!

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:uT**************@TK2MSFTNGP14.phx.gbl...
Can't say that I follow. What's in the database now? The entire literal
string from "[[imagediv..." to "placeholding use only."? All in one
column? What is the purpose of this data? What are you trying to acheive
here?

Ray at work

"bateman" <ba********@nospam.hotmail.com> wrote in message
news:OK**************@TK2MSFTNGP10.phx.gbl...
Hi, what I am trying to do is the following, its causing some probs
though:

I have the following in a database:
[[imagediv 100.jpg This is the description text]]
This is just some dummy text. It doesn't mean anything and is for
placeholding use only.

And want to change it to:
<div class="imagediv"><img src="/images/100.jpg" alt="100.jpg"
width="200" height="200" /><br />
This is the description text</div>
This is just some dummy text. It doesn't mean anything and is for
placeholding use only.

In the future I might want to use different codes ie [[imagediv 100.jpg
This is the description text]] to reference a different DIV.

Any ideas?


Jul 22 '05 #3
If the end user doesn't see [[imagediv 100.jpg This is the description
text]] then why not, when they click the button, just create the whole code?

Store <img scr=100.jpg alt='This is the description text'> etc...

Why build two steps to creating HTML? It's HTML, not hyroglyphics...

--
http://www.aspfaq.com/
(Reverse address to reply.)


"bateman" <ba********@nospam.hotmail.com> wrote in message
news:ud**************@TK2MSFTNGP09.phx.gbl...
Hi, sorry about that.
Yeah if I return the field from the database I get:

[[imagediv 100.jpg This is the description text]]
This is just some dummy text. It doesn't mean anything and is for
placeholding use only.

The reason for this is that I am trying to write a system for a user to
easily add a article, the bits in [[ ]] will be created by buttons they
press making it hopefully pretty much foolproof. I don't trust them with
real code!

There could be multiple instances of this in the field so what I was hoping I could do was something like this (written in non-code code!)

Take the returned field
Go through it
if you find [[ take out the text between [[ and ]]
split into 3 parts, the first word (imagediv in this case), the picture name (100.jpg) and the description text (This is the description text)
Then replace the [[ ...... ]] with
<div class="imagediv"><img src="/images/100.jpg" alt="100.jpg" width="200"
height="200" /><br />This is the description text</div>

Then I can use the modified string in my code, hopefully showing the picture without ever having to explain what a DIV is!

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:uT**************@TK2MSFTNGP14.phx.gbl...
Can't say that I follow. What's in the database now? The entire literal string from "[[imagediv..." to "placeholding use only."? All in one
column? What is the purpose of this data? What are you trying to acheive here?

Ray at work

"bateman" <ba********@nospam.hotmail.com> wrote in message
news:OK**************@TK2MSFTNGP10.phx.gbl...
Hi, what I am trying to do is the following, its causing some probs
though:

I have the following in a database:
[[imagediv 100.jpg This is the description text]]
This is just some dummy text. It doesn't mean anything and is for
placeholding use only.

And want to change it to:
<div class="imagediv"><img src="/images/100.jpg" alt="100.jpg"
width="200" height="200" /><br />
This is the description text</div>
This is just some dummy text. It doesn't mean anything and is for
placeholding use only.

In the future I might want to use different codes ie [[imagediv 100.jpg
This is the description text]] to reference a different DIV.

Any ideas?



Jul 22 '05 #4
Why don't you keep the image name and description in seperate columns in the
DB?

Why does the user have to know anything about <div>? Can't you just output
that in the code?

Why are you are making it so hard on yourself with contrived data formats?
Bob Lehmann

"bateman" <ba********@nospam.hotmail.com> wrote in message
news:ud**************@TK2MSFTNGP09.phx.gbl...
Hi, sorry about that.
Yeah if I return the field from the database I get:

[[imagediv 100.jpg This is the description text]]
This is just some dummy text. It doesn't mean anything and is for
placeholding use only.

The reason for this is that I am trying to write a system for a user to
easily add a article, the bits in [[ ]] will be created by buttons they
press making it hopefully pretty much foolproof. I don't trust them with
real code!

There could be multiple instances of this in the field so what I was hoping I could do was something like this (written in non-code code!)

Take the returned field
Go through it
if you find [[ take out the text between [[ and ]]
split into 3 parts, the first word (imagediv in this case), the picture name (100.jpg) and the description text (This is the description text)
Then replace the [[ ...... ]] with
<div class="imagediv"><img src="/images/100.jpg" alt="100.jpg" width="200"
height="200" /><br />This is the description text</div>

Then I can use the modified string in my code, hopefully showing the picture without ever having to explain what a DIV is!

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:uT**************@TK2MSFTNGP14.phx.gbl...
Can't say that I follow. What's in the database now? The entire literal string from "[[imagediv..." to "placeholding use only."? All in one
column? What is the purpose of this data? What are you trying to acheive here?

Ray at work

"bateman" <ba********@nospam.hotmail.com> wrote in message
news:OK**************@TK2MSFTNGP10.phx.gbl...
Hi, what I am trying to do is the following, its causing some probs
though:

I have the following in a database:
[[imagediv 100.jpg This is the description text]]
This is just some dummy text. It doesn't mean anything and is for
placeholding use only.

And want to change it to:
<div class="imagediv"><img src="/images/100.jpg" alt="100.jpg"
width="200" height="200" /><br />
This is the description text</div>
This is just some dummy text. It doesn't mean anything and is for
placeholding use only.

In the future I might want to use different codes ie [[imagediv 100.jpg
This is the description text]] to reference a different DIV.

Any ideas?



Jul 22 '05 #5
bateman wrote on 23 nov 2004 in microsoft.public.inetserver.asp.general:
[[imagediv 100.jpg This is the description text]] <div class="imagediv"><img src="/images/100.jpg" alt="100.jpg"
width="200" height="200" /><br />This is the description text</div>


it is simple string manipulation.

Using vbscript:

================================

s = "[[imagediv 100.jpg This is the description text]]"

s= replace(s,"[[","")
s= replace(s,"]]","")

a = split(s," ")

r = "<div class='" & a(0) & "'>"

r = r & "<img src='/images/" & a(1) & "' alt='" & a(1)

r = r & "' width='200' height='200' /><br />"

for i=2 to ubound(a)
r = r & a(i) & " "
next

result = left(r,len(r)-1) & "</div>"

================

Instring HTML quotes are replaced with single ones.

I would put the width and height in the css clas description

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)

Jul 22 '05 #6
On Mon, 22 Nov 2004 23:01:04 -0000, "bateman"
<ba********@nospam.hotmail.com> wrote:
Hi, what I am trying to do is the following, its causing some probs though:

I have the following in a database:
[[imagediv 100.jpg This is the description text]]
This is just some dummy text. It doesn't mean anything and is for
placeholding use only.

And want to change it to:
<div class="imagediv"><img src="/images/100.jpg" alt="100.jpg" width="200"
height="200" /><br />
This is the description text</div>
This is just some dummy text. It doesn't mean anything and is for
placeholding use only.

In the future I might want to use different codes ie [[imagediv 100.jpg This
is the description text]] to reference a different DIV.

Any ideas?


First idea is to stop trying to do this. Keep data in the database,
markup in your page language. Second is to learn to use a database.
The image file name is an attribute. The image description is an
attribute. Attributes define your columns. So you should have:

ImageNumber - An autoassigned number to use as a unique key
ImageFileName - The actual file name (possibly with path, or a
separate column for path)
ImageDescription - The descriptive text about the image.

Retrieve the image file name from your database, display that file
along with the description.

And until the user places the data in the database, you don't need a
place holder. Don't create the record.

Jeff
Jul 22 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: rbt | last post by:
Here's the scenario: You have many hundred gigabytes of data... possible even a terabyte or two. Within this data, you have private, sensitive information (US social security numbers) about your...
38
by: Jukka K. Korpela | last post by:
As well all know, valid markup is important... but when trying to find a convincing modern argument in favor of this, I found pages like http://www.htmlhelp.com/tools/validator/reasons.html which...
4
by: Lukasz Indyk | last post by:
hello;) i have a piece of html code, and want to replace every image on my page with this code. now i do it by replacing IMG node with SPAN node, and then setting innerHTML property of SPAN node...
12
by: Brian | last post by:
I want to use regxp to check that a form input contains at least 1 non-space charcter. I'd like to only run this if the browser supports it. For DOM stuff, I'd use if (documentGetElementById) {}...
19
by: Paul | last post by:
hi, there, for example, char *mystr="##this is##a examp#le"; I want to replace all the "##" in mystr with "****". How can I do this? I checked all the string functions in C, but did not...
5
by: Casey | last post by:
Hello, Can someone give me specific code to replace text on a page using server side javascript? I need to use server-side because I need the output to be recognized in the final HTML so that...
3
by: gregpinero | last post by:
Hi guys, What I'm trying to do is find all instances of an acronymn such as IBM on a webpage and replace it with <acronym title="International Business Machines">IBM</acronym>. However in my...
9
by: Daniele Perilli | last post by:
Hi everybody, I'd like to introduce you a new little tool I developed to automatically check markup validation of all pages in given websites. It uses W3C HTML Validator and CSS Validator online...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.