Replace markup with real code

Discussion in 'ASP General' started by bateman, Nov 22, 2004.

  1. bateman

    bateman Guest

    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?
     
    bateman, Nov 22, 2004
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:...
    > 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?
    >
     
    Ray Costanzo [MVP], Nov 22, 2004
    #2
    1. Advertising

  3. bateman

    bateman Guest

    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:...
    > 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" <> wrote in message
    > news:...
    >> 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?
    >>

    >
    >
     
    bateman, Nov 22, 2004
    #3
  4. 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" <> wrote in message
    news:...
    > 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:...
    > > 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" <> wrote in message
    > > news:...
    > >> 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?
    > >>

    > >
    > >

    >
    >
     
    Aaron [SQL Server MVP], Nov 23, 2004
    #4
  5. bateman

    Bob Lehmann Guest

    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" <> wrote in message
    news:...
    > 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:...
    > > 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" <> wrote in message
    > > news:...
    > >> 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?
    > >>

    > >
    > >

    >
    >
     
    Bob Lehmann, Nov 23, 2004
    #5
  6. bateman

    Evertjan. Guest

    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)
     
    Evertjan., Nov 23, 2004
    #6
  7. bateman

    Jeff Cochran Guest

    On Mon, 22 Nov 2004 23:01:04 -0000, "bateman"
    <> 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
     
    Jeff Cochran, Nov 23, 2004
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. senthil
    Replies:
    5
    Views:
    1,391
    senthil
    Jan 24, 2004
  2. Toska
    Replies:
    1
    Views:
    348
    =?ISO-8859-1?Q?Anders_Nor=E5s?=
    Jan 30, 2005
  3. Toska
    Replies:
    0
    Views:
    313
    Toska
    Jan 31, 2005
  4. Curious Trigger
    Replies:
    2
    Views:
    1,817
    Curious Trigger
    Sep 9, 2006
  5. JX
    Replies:
    5
    Views:
    584
    Mark Rae [MVP]
    Jan 23, 2008
Loading...

Share This Page