Mixing HTML & LC

Are you using LiveCode to create server scripts or CGIs?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Posts: 19
Joined: Thu Sep 04, 2014 3:32 pm

Mixing HTML & LC

Post by paulrichards999 » Fri Feb 10, 2023 9:49 pm

I've been playing with Livecode server recently, but what seems obvious to me , or would work in livecode, doesn't appear to work in webpage.

Example - login page

It posts username and password to another LC page that does it's bit, and if invalid returns user back to login page with an error ie: login.lc?error=1 (this part all works fine and as expected)

I'm trying this in the location i wish the error to appear
Global gErrText
If gErrText is not empty then
Put "<div class="alert alert-danger" role="alert">"
Put "<strong>"&gErrtext&"</strong>"
put "</div>"
end if

This line" Put "<div class="alert alert-danger" role="alert">" (or any line with mention of class) results in a livecode error
file "E:/SERVER/Apache24/htdocs/login.lc"
row 76, col 32: put: preposition must be 'before', 'into' or 'after' (alert)
row 76, col 32: if: error in command (alert)
row 76, col 32: script: bad statement (alert)

How do I use html code with put statements, other than basic <p> <strong> etc tags ? Or how to make them HTMl/lc friendly without manual dibbling of html string.


Posts: 26
Joined: Thu Jan 17, 2019 6:43 am

Re: Mixing HTML & LC

Post by cpuandnet » Fri Feb 10, 2023 10:56 pm

Hi Paul,

At first glance, I believe it may be an inner quote issue with the first put statement.

Try this:

Code: Select all

Put "<div class=" & quote & "alert alert-danger" & quote & " role=" & quote & "alert" & quote & ">"
Also, when posting to the forum, you should always post your code inside of the code display markup keywords.

I hope this helps.


VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 115
Joined: Tue Feb 23, 2010 10:53 pm
Location: Saint Louis, Missouri USA

Re: Mixing HTML & LC

Post by bobcole » Sat Feb 11, 2023 4:43 pm

I think the problem is with the space character and the hyphen in the class:
Put "<div class="alert alert-danger" role="alert">"
Try putting an underscores in their places.

Code: Select all

Also make this change in the css definition (or wherever is used).
Hope that helps.

Post Reply

Return to “CGIs and the Server”