• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

converting javascript variable to coldfusion

Guest
May 30, 2008 May 30, 2008

Copy link to clipboard

Copied

I am running a form that submits data via the cf ajax to a .cfc file --
when it returns to the calling page -- i turn the forms into text and remove the form fields.
the problem is i run the statement:
document.getElementById("PROGRAM_TYP").innerHTML = document.myform.PROGRAM_TYP.value;

most of the items submitted are just text values and the value of the form field is the actual display text which then populates correctly.
in this case -- the form field is a select where and ID is used -- so when i go to populate the <td> with the submitted value -- it only puts in the ID (as this was the actual submitted value)

i am trying to take this submitted value and resolve the ID back to the display value and use this value in place of the document.myform.PROGRAM_TYP.value

what i need to be able to do is convert the document.myform.PROGRAM_TYP.value into something i can plug into CFQUERY.
or use the <cfreturn> to return and catch a specific variable.
TOPICS
Advanced techniques

Views

717

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 02, 2008 Jun 02, 2008

Copy link to clipboard

Copied

It seems you need to change the value of id attribute of <option> tags.

Can you try removing the id attribute from select? Or use such values for id attribute that can be used in the action page

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 06, 2008 Jun 06, 2008

Copy link to clipboard

Copied

i think i used the wrong wording in my original question.
the ID i was referring to was the database ID value
like query of:
ID NAME
1 Red
2 Blue
3 Green

in my select statement -- the ID is the value that is submitted by the form and held in the database. (not the ID of an html tag).
so when the form is submitted - i have the value but not the database resolved value of that field.
for instance the form value was 2, the code places 2 into the corresponding database field. but i want to now display the value of 2 in clear text as 'Blue' -- i am trying to do this via a query that was run and have the result passed from the cfc to the webpage to populate the innerHTML value

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 10, 2008 Jun 10, 2008

Copy link to clipboard

Copied

LATEST
How about using another Hidden input field that is bound to the value you select and looks up its value as you select 1, 2, or 3.

<cfselect name="select_color">
<option value="1 Red">1 Red</option>
...
...
</cfselect>
<cfinput type="hidden" name="hidden_color" bind="cfc:cfc_filename.method_name({select_color})" />

Your method in your CFC would have to return the query value of Red if select_color was selected as 1 Red, then you could use the document.formName.hidden_color.value in your javascript.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation