Wrox Programmer Forums
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 28th, 2004, 10:32 PM
Authorized User
 
Join Date: Jan 2004
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Default form submit problem

hi all

i have a form with a few fields for user to enter, there's also a button which when clicked, a new textarea that has a html editor attached to it created, if the button is clicked again, the textarea will be removed.

the only problem is if i press the button 2 times, i.e. create the textarea then remove it again, when i try to submit my form, an error msg will popup informing me that something is null.

i know that e error is refering to my external javascript which creates the html editor, how do i solve this?

instead of pasting the code here, i pasted my code into notepad
http://www.geocities.com/dhaywirex/add.txt --my form's code
http://www.geocities.com/dhaywirex/editor.js --the html editor code
http://www.geocities.com/dhaywirex/editor.txt --if the one above cant work
 
Old March 29th, 2004, 04:43 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

I took a look but it's a lot of code, what exactly is null?

--

Joe
 
Old March 29th, 2004, 05:27 AM
Authorized User
 
Join Date: Jan 2004
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ok..heres the short stuff, when the button is clicked, it will call a function in editor.js, supply it with the name of the textarea created with panels.innerHTML = "<textarea name='panel' cols='50' rows='5' id='panel'></textarea>", and the function will create the html editor.
if i submit the form now, no problem
if i close the textarea, i.e. panels.innerHTML = "", the error, document.all[...].config is null or not an object will appear

the exact function called when button is clicked
function createForm() {
if (panelflag == false) {
  data = "<textarea name='panel' cols='50' rows='5' id='panel'></textarea>"
  document.form1.btn.value = "Remove Panels";
  panelflag = true;
}
else {
  data = "";
  document.form1.btn.value = "Add Panels";
  panelflag = false;
}

if (document.layers) {
  document.layers.panels.document.write(data);
  document.layers.panels.document.close();
}
else {
  if (document.all) {
    panels.innerHTML = data;
  }
}

if (panelflag == true) {editor_generate('panel');} 'from editor.js
}


the relevant function in editor.js where the error occured
function editor_generate(objname,userConfig) {
  // Default Settings
  var config = new editor_defaultConfig(objname);
  if (userConfig) {
    for (var thisName in userConfig) {
      if (userConfig[thisName]) { config[thisName] = userConfig[thisName]; }
    }
  }
  document.all[objname].config = config; 'i believe this is where error occured // store config settings
blah blah blah...lots more codes

hope this makes its easier to find out whats wrong
1 more thing, if i actually 'close' my textarea 3 times, the error will appear 3 times, close the textarea 2 times, and the error will pop up 2 times.....






Similar Threads
Thread Thread Starter Forum Replies Last Post
WebRequest/WebResponse form submit problem. HELP! MAtkins ASP.NET 1.0 and 1.1 Professional 2 December 23rd, 2010 12:28 AM
form submit problem alexscan Beginning PHP 0 January 1st, 2008 08:37 PM
form submit problem/dependent list menus alexscan Pro PHP 0 January 1st, 2008 06:29 PM
Form Submit Problem. muklee Javascript 7 May 27th, 2007 10:06 PM
Firefox Problem - submit form mattastic Javascript How-To 4 July 19th, 2005 07:30 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.