Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9118587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:11:22+00:00 2026-06-17T05:11:22+00:00

I am trying to manually set a variable INSIDE a form, because it contains

  • 0

I am trying to manually set a variable INSIDE a form, because it contains html and placing it in the value attribute of a tag would cause errors in the display. Currently, I check to see if that attribute contained html, and if so, the field is empty.

I’d like to be able to set the variable as the old value if it contained html in previous entries of the form, so that the user wouldn’t have to enter that field every time they loaded that ORM object to edit.

Here’s a snippet:

<cfif ("#dataobject.getField()#" NEQ "" AND Left(dataobject.getField(), 1) EQ "<")>
<cfscript>
    temp = dataobject.getField();
    temp2=temp;
    temp2 = Insert("---", temp2, 0);
    temp2 = Insert("<!", temp2, 0);
    temp2 = Insert("--->", temp2, Len(temp2));
    dataobject.setField(temp2);                             
</cfscript>

<label for="name">
    Field:
</label>
<input type="text" name="Field" value="">
<button id="savefield" name="savefield">Save</button>
<cfif form.Field EQ ""><cfset form.Field = temp></cfif>
<cfscript>
    dataobject.setField(temp);
</cfscript>

<cfelse>
<label for="name">
    Field:
</label>
<input type="text" name="Field" <cfif ("#dataobject.getField()#" NEQ "")>value="#dataobject.getField()#"</cfif>>
<button id="savefield" name="savefield">Save</button>
</cfif>

The code I was trying to use:
<cfif form.Field EQ ""><cfset form.Field = temp></cfif>

Coldfusion throws an error saying that the FORM variable is undefined (which doesn’t surprise me). The “savefield” button calls javascript that opens a window allowing the user to set the value, then closes. Should I put my code there instead?

-The inserts which turn the string into a comment was an early attempt at a workaround that didn’t work :/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T05:11:23+00:00Added an answer on June 17, 2026 at 5:11 am

    Ok hopefully the following pointers will help you going:

    • Verify that the field exists in the form via; structKeyExists(form, “field”) or use cfparam to initialize a default value
    • Escape the value with HTMLEditFormat(dataObject.getField()) to escape any HTML code which breaks the html

    So e.g.;

    <cfparam name="form.field" default="" />
    
    <label for="field">
        Field:
    </label>
    <input type="text" id="field" name="field" value="#htmlEditFormat(form.field)#" />
    <button id="savefield" name="savefield">Save</button>
    

    Gl !

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a strange effect when trying to manually set the data-url attribute on
I am trying to set a javascript global var using jquery and dynamic variable
I am trying to manually set values of variables using jstl syntax. <c:set var=var1
I'm trying to manually set an object in the Django cache API but it
Currently trying to find a way to do the following inside some form of
I am trying to set up some path using environment variable. I added an
I am trying to set an identity field's value before inserting the new record
I always wondered why I have to manually set the JAVA_HOME environment variable after
I'm trying to manually manage some geometry (spatial) columns in a rails model. When
Following a MSDN web page, I am trying to manually run mstest within my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.