ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
You don't need a fax machine to get faxes. Get a fax-to-email fax number from CallWave. Try it free.
  #1  
Old March 6th, 2004, 11:28 AM
saxy46 saxy46 is offline
SWAT
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: baltimore
Posts: 5 saxy46 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 12 sec
Reputation Power: 0
Send a message via AIM to saxy46 Send a message via MSN to saxy46
Cold Fusion Forms

Hey,
I am creating a form in cold fusion, that will connect to the database. The form will work in this fashion: Question 1, if you ansered yes, then go to next question. If answer is no, then prompt a new field to explain why. This field appears when the user clicks "no". This is how each of the questions are set up. I'm not quite sure how to generate that new field when the "no" box is clicked. Any suggestions? Thanks

Reply With Quote
  #2  
Old March 7th, 2004, 12:06 PM
ColdFusionCart ColdFusionCart is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 11 ColdFusionCart User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Talking JavaScript is the answer with hidden fields on the next page's form

What you will do is put some JavaScript in the <head></head> tags of your page.

I have written the page for you in clean HTML and JavaScript, email me at support@ColdFusionCart.com if you have any more questions, but this page is simply, a little fancy, will run in IE and Netscape and can be adjusted very easily for your project:

I wrote you this HTML page and here's what it does:

1) User comes to the page and gets asked a question.

2) If he picks nothing, then we give him a warning telling him that he better select an answer, whether Yes or No.

3) IF he picks Yes, then we let him go on his merry way to the next page (next_page.cfm)

4) IF he picks No, then we give him a warning, telling him he had better give us a reason why he is picking No. Then all the sudden a text box will magically appear on the screen and tell him that he can enter his answer inside of it.

5) IF he picks No, then he CANNOT leave the page until he gives us a reason why he picked No.

I have debugged this for you and it works beautifully:

<html>
<head>

<!----paste this JavaScript code into your <head></head> tags---->
<script language="JavaScript">

function checkIfNo(){

//if he picks nothing, then let's set everything back to null values
if (document.myForm.someFormField.value == '')

{
myDiv.style.visibility = 'hidden';
}

//if he picks No, then open the text box and un-disable it because we are going to FORCE him to tell us why he ain't using it
if (document.myForm.someFormField.value == 'No')

{
alert('You selected No, so please tell us why you are selecting No as your answer!');
myDiv.style.visibility = 'visible';
}

//if he picks Yes, then hide the text box because he can leave freely as he wishes to the next page
if (document.myForm.someFormField.value == 'Yes')

{
myDiv.style.visibility='hidden';
}

}

function askMeWhy(){

//first make sure the value of the drop-down menu is NOT NULL
if (document.myForm.someFormField.value == '')

{
//give the message that he forgot to answer the question
alert('What about answering the question in the first place?!?');

//put the mouse in the field for him to hold his hand a little through the forms process
document.myForm.someFormField.focus();

//don't let him go anywhere yet becuase he hasn't got his facts straight
return false;
}

//this JavaScript function can be used to make sure that if the user clicks "No", then he MUST fill in an answer
//in the text box in the form.....only then can he submit the form to the next page

//if "No" button is checked, then we will un-disable the textbox, tell him to type something in it, and then NOT let him
//leave the page until he has filled in the text box with the reason why he picked "No"

if (myDiv.style.visibility == 'visible')

{

if (myForm.myTextBox.value == '')

{
alert('Enter your Reason Here!');
myForm.myTextBox.focus();
return false;
}

}

}

</script>

</head>

<body>

<p><strong>Hello and welcome to this form - fill it out or else!</strong>

<p>

<form action="next_page.cfm" method="post" name="myForm" onSubmit="return askMeWhy();">

<table width="100%" cellpadding="2" cellspacing="2" border="0">
<tr>
<td width="32%" valign="top">

<p>Do you need a Cold Fusion Shopping Cart?

<p>

<!----here are your radio buttons, set the default to Yes if you want by saying and optional 'checked' in its field---->
<select name="someFormField" onChange="checkIfNo();">
<option value="">Select on the these answers</option>
<option value="Yes">Yes, I need a Cold Fusion Shopping Cart</option>
<option value="No">No, I don't need a Cold Fusion Shopping Cart</option>
</select>

</td>
<td width="68%" valign="top">

<!----you have to put this one inside a "div" so you can hide it when they select yes but shove it in their face when they select No---->
<div id="myDiv" style="position:absolute; visibility:hidden;">

<p>You selected <strong>"No"</strong> as your answer, please fill in your reason here:
<br><textarea cols="55" rows="5" name="myTextBox"></textarea>

</div>

</td>
</tr>
</table>

<p><input type="submit" value="Go To Next Page!">

</form>

</body>
</html>

Marc
Software Engineer
Cold Fusion Shopping Cart
support@ColdFusionCart.com
www.ColdFusionCart.com

Reply With Quote
  #3  
Old March 7th, 2004, 05:45 PM
saxy46 saxy46 is offline
SWAT
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: baltimore
Posts: 5 saxy46 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 12 sec
Reputation Power: 0
Send a message via AIM to saxy46 Send a message via MSN to saxy46
thanks! i'll check it out and let ya know if I have any questions. I appreciate your help!

Reply With Quote
  #4  
Old March 8th, 2004, 09:23 AM
saxy46 saxy46 is offline
SWAT
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: baltimore
Posts: 5 saxy46 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 12 sec
Reputation Power: 0
Send a message via AIM to saxy46 Send a message via MSN to saxy46
Question

I applied the code and it works great. I'm not that formiliar with javascript, so I am having some trouble having multiple questions on the page. I thought I was doing it right but apparently not. Can you please help? I appreciate it. Thanks!

Reply With Quote
  #5  
Old March 8th, 2004, 04:29 PM
ColdFusionCart ColdFusionCart is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 11 ColdFusionCart User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Sure thing - just email me your code and I will help you out

Sure thing - just email me your code @ support@ColdFusionCart.com and I will be happy to take a look.

Reply With Quote
  #6  
Old March 10th, 2004, 04:05 PM
saxy46 saxy46 is offline
SWAT
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: baltimore
Posts: 5 saxy46 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 12 sec
Reputation Power: 0
Send a message via AIM to saxy46 Send a message via MSN to saxy46
thanks! I emailed ya the code.

Quote:
Originally Posted by ColdFusionCart
Sure thing - just email me your code @ support@ColdFusionCart.com and I will be happy to take a look.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Cold Fusion Forms


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway