3 Replies - 1231 Views - Last Post: 01 June 2009 - 06:26 AM Rate Topic: -----

#1 Ennio  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 26
  • Joined: 29-May 08

Crazy Form error

Posted 29 May 2009 - 08:54 AM

I have a CFForm tag in my code that has a simple input box, a rich textarea, and a couple of more inputs.

But some of the iputs are generated dynamically with AJAX. For example, the user can creat a Poll so they can add as many answer as they want.

everythings works fine in Internet Explorer, but on FireFox I cannot get the dynamic content. For some reason when I submit the page it does not work and coldfusion tells me that the input is not defined.

The problem is only for the TEXTAREA.

why is that? how can i fix that?


Thanks :)

This post has been edited by Ennio: 29 May 2009 - 09:01 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Crazy Form error

#2 xheartonfire43x  Icon User is offline

  • D.I.C Regular

Reputation: 46
  • View blog
  • Posts: 454
  • Joined: 22-December 08

Re: Crazy Form error

Posted 29 May 2009 - 10:33 AM

View PostEnnio, on 29 May, 2009 - 07:54 AM, said:

I have a CFForm tag in my code that has a simple input box, a rich textarea, and a couple of more inputs.

But some of the iputs are generated dynamically with AJAX. For example, the user can creat a Poll so they can add as many answer as they want.

everythings works fine in Internet Explorer, but on FireFox I cannot get the dynamic content. For some reason when I submit the page it does not work and coldfusion tells me that the input is not defined.

The problem is only for the TEXTAREA.

why is that? how can i fix that?


Thanks :)


We need to see some code to help you.
Was This Post Helpful? 0
  • +
  • -

#3 Ennio  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 26
  • Joined: 29-May 08

Re: Crazy Form error

Posted 29 May 2009 - 10:47 AM

Here is the JS that I use to create the new input fields (TEXTAREA) when the user click on add poll in my FORM, also they will be able to add more answers to the poll.

// Javascript Document

		function enablePoll(){
			document.getElementById('pollenabled').value = 'Yes';
			document.getElementById('rightContent').style.width = '';
			
		}
		function focusTitle() {
			// IE has issues with focusing the title field right away. weird, huh ?
			setTimeout('document.authorform.Title.focus()', 300);			
		}
		addToonload(focusTitle);

		function removeAskRxCategory() {
			var control = document.getElementById("lst_Category");
			if (control) {
				for (var i = 0; i < control.options.length; i++) {
					if (control.options[i].text.toLowerCase() == 'askrx answers'){
						control.remove(i);
						break;
					}
				}
			}
		}
		addToonload(removeAskRxCategory);
		
		function cancelAuthor() {
			
			if (confirm("Are you sure you want to cancel this poll?")) {
				window.close();
				/*document.authorform.cancel.value="true";
				SermoForms['authorform'].submit();*/
			}
		}
		
		function showPreview() {
			var oldtarget = document.authorform.target;
			var oldaction = document.authorform.action;
			var win = browserPopup('cfc_poll_preview.cfm','preview',600,500);
			win.focus();
			document.authorform.action = 'ticket/author/preview';
			document.authorform.target = 'preview';
			document.authorform.submit();
			document.authorform.target = oldtarget;
			document.authorform.action = oldaction;
		}

		function addImage() {			
			var oldtarget = document.authorform.target;
			var oldaction = document.authorform.action;
			//var newText = getHTML('edt_content_ifr');
			//setText('edt_content_ifr', newText);
			var win = browserPopup('ticket/author/uploadimage','preview',500,350);
			if (win) {
				win.focus();
			}			
			document.authorform.action = 'ticket/author/uploadimage';
			document.authorform.target = 'preview';
			document.authorform.submit();
			document.authorform.target = oldtarget;
			document.authorform.action = oldaction;
		}	

		function cancelImage() {
			document.authorform.removeImage.value = "true";
			document.authorform.submit();
		}
		
		function backStep() {
			document.authorform.step.value="Split";
			document.authorform.target = null;
			document.authorform.submit();
		}

		function toggleQuestion(idx) {

			delAllAnswers();
			setQuestionDisplay('none');

			switch(idx) {
			case 0:
				addAnswer("Yes");
				addAnswer("No, never");
				setQuestion("Have you seen this?");
				break;

			case 1:
				addAnswer("Yes");
				addAnswer("No");
				setQuestion("Do you agree?");
				break;

			case 2:
				addAnswer("");
				setQuestion("How would you explain this?");
				break;

			case 3:
				addAnswer("");
				setQuestion("");
				setQuestionDisplay('block');
				break;

			default:
				addAnswer("");
				setQuestion("");
				break;
			}

		}

		function setQuestion(qText) {

			var question = document.getElementById("edt_question");
			if (question) {
				question.innerHTML  = qText;
				question.value	  = qText;
			}

		}

		function setQuestionDisplay(display) {

			var question = document.getElementById("edt_question");
			if (question) {
				question.style.display = display;
			}
		}

		function delAllAnswers() {

			var table = document.getElementById("displayedAnswers");
			if (table) {
				for (var i = (table.rows.length-1); i > 0; i--) {
					table.deleteRow(i);
				}
			}
		}

		function delAnswer(span) {

			var table = document.getElementById("displayedAnswers");
			if (table) {

				// find the parent TR and delete 
				var tr  = span.parentNode.parentNode;
				var idx = tr.rowIndex;
				table.deleteRow(idx);

				// clean up the names and IDs of remaining rows
				var tdLeft, tdRight, textarea;
				var i = idx;
				for (i; i < table.rows.length; i++) {
					tr = table.rows[i];

					tdLeft = tr.cells[0];
					tdLeft.childNodes[1].innerHTML = '&nbsp;' + i + ')&nbsp';

					tdRight		 = tr.cells[1];
					textarea		= tdRight.getElementsByTagName('textarea')[0];
					textarea.id	 = 'edt_answer_' + (i-1) + '_content';
					textarea.name   = 'answer_' + (i-1) + '_content';

				}
			}

		}

		function addAnswer(ans) {

			var table = document.getElementById("displayedAnswers");
			if (table) {

				var tr	  = table.insertRow(-1);
				var tdLeft  = tr.insertCell(-1);
				var tdRight = tr.insertCell(-1);

				tdLeft.className	= 'qAnswerIdx';
				tdLeft.innerHTML	= '<img id=\"img_delAnswer\" onclick="delAnswer(this)" class="delAnswer" src="http://cfcenters.com/members/ui/images/polls/deletewhite-o.png" width="9" height="11" alt="Delete" title="Delete this answer" /><span>&nbsp;' + tr.rowIndex + ')&nbsp;</span>';

				tdRight.style.verticalAlign = 'top';

				var textarea = document.createElement('textarea');
				textarea.style.width	= '200px';
				textarea.style.height   = '5em';
				textarea.id			 = 'edt_answer_' + (tr.rowIndex-1) + '_content';
				textarea.name		   = 'answer_' + (tr.rowIndex-1) + '_content';
				textarea.maxlength	  = '1000';
				textarea.innerHTML	  = ans;
				textarea.onblur = new Function("textAreaValidate(this, 1000)");
				textarea.onkeyup = new Function("textAreaValidate(this, 1000)");
				tdRight.appendChild(textarea);
				textarea.focus();
			}

		}
		
		function trim(str)
		{
			s=str.replace(/^(\s)*/,"");
			s=s.replace(/(\s)*$/,"");
			return s;
		}
  function showNext() {
			// ensure all answers have a value
			var i = 0;
			var trimmed;
			
			var question = document.getElementById('edt_question');
			var type = document.getElementById("rad_pType2");

				if(trim(question.value).length < 1){
					toggleError("questionerror","block");
					return(false);
				}
				else{
					toggleError("questionerror",'none');
					var textarea = document.getElementById('edt_answer_' + i + '_content');
					while(textarea != null) {					
						trimmed = trim(textarea.value);
						if (trimmed.length < 1) {
							toggleError("answerError","block");
							return(false);
						}				   
						i++;
						textarea = document.getElementById('edt_answer_' + i + '_content');
					}
					toggleError("answerError","none");
				}
		 
		 	document.authorform.submit();
			/*SermoForms['authorform'].submit();*/
		}

		

	
		function toggleError(element, display){
			var ele = document.getElementById(element);
			if(ele != null){
				ele.style.display = display
			}
		}


		function toggleSurvey(idx) {
			var toggledDiv = document.getElementById("questionsAndAnswers");
			var reminderDiv = document.getElementById("surveyOnReminder");
			switch(idx) {
			case 0:	   	 	
				if (toggledDiv) {
			   	 	toggledDiv.style.display = 'block';
			   	 	reminderDiv.style.display = 'none';
			   	 	
			   	 	var previewButton = document.getElementById("btn_Preview");
			   	 	
			   	 	previewButton.disabled = false;
	   				juggleClass(previewButton, "disabled", 0);
				  }
				break;				
			case 1:
				if (toggledDiv) {
			   	 	toggledDiv.style.display = 'none';
			   	 	reminderDiv.style.display = 'block';
			   	 	
			   	 	var previewButton = document.getElementById("btn_Preview");
			   	 	previewButton.disabled = true;
	   				juggleClass(previewButton, "disabled", 1);			   	 	
				  }				
				break;
			}
		
		}
	// -->




This code works perfect in IE, but not on FireFox
Was This Post Helpful? 0
  • +
  • -

#4 xheartonfire43x  Icon User is offline

  • D.I.C Regular

Reputation: 46
  • View blog
  • Posts: 454
  • Joined: 22-December 08

Re: Crazy Form error

Posted 01 June 2009 - 06:26 AM

View PostEnnio, on 29 May, 2009 - 09:47 AM, said:

Here is the JS that I use to create the new input fields (TEXTAREA) when the user click on add poll in my FORM, also they will be able to add more answers to the poll.

This code works perfect in IE, but not on FireFox


This is the coldfusion forum... not Javascript.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1