Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trickey question on forms

Status
Not open for further replies.

Bramvg

IS-IT--Management
Jan 16, 2001
135
BE
Hi there,

Project:
The project I'm working on is a site where you can do some tests. E.g.: capture with multiple choice, dropdown list, text input, checkboxes,...

Database:
Each question has a reference to a 'question type', e.g. textbox, multiple choice,...


Problem:
Our content manager would like to asks questions where someone has to enter text in a textbox inside the question.
e.g.: Yesterday I [.....] to the hairdresser, but he [.....] not want to cut my hair.

Script?
If this was hard coded, no problem. But now I have to check the 'question type' in my database, and I need some reference in my 'question' itself, so I know to replace that piece of code in the question with a 'input type=type' box.

Question:
Does anyone of you know how I should code the question, so it can check where to put an 'input type=text" box?

When I retrieve my question from the database, I know it's one with [multiple] text boxes, but how do I code it that it will replace 'the code' [a special tag?] with an input type=text box?


Many thanks in advance if you take your time to help me out.
bram



 
Hey Bram,

Is there any reason you wouldn't just put the question in the database with the text box code included in the text? I don't see any reason why you couldn't put &quot;My favorite class is <input type=&quot;text&quot; name=&quot;fav_class&quot;>&quot; directly in your table. If you have a page where you edit the questions, just use the htmleditformat() function to properly escape the text.

If you really want to place a token in there instead of the full text, just choose something like <fav_class> to denote a text box. When you go to display it, just do a <cfoutput>#replace(replace(q1.pageText,&quot;<&quot;,&quot;<input type=&quot;&quot;text&quot;&quot; name=&quot;&quot;&quot;,&quot;all&quot;),&quot;>&quot;,&quot;&quot;&quot;>&quot;)#</cfoutput>. This should build a text box around the name &quot;fav_class&quot;.

You just have to make sure that your sequence denoting a text box isn't used anywhere else in a normal context.

Hope this helps,
GJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top