PDA

View Full Version : Syntax help needed please


The14thGOD
04-11-2007, 07:30 AM
Hey,

I'm not totally familiar with Javascript so I get confused with syntax.

I am trying to add a hidden field to a edit form, heres the code:

editbox += '<input type="hidden" name="type" value="' + type + '" />';

type is a variable that is predefined elsewhere, likewise with editbox, this worked b4 I added this line of code.

Firebug, says:
reference to undefined property "editbox"
editText("10")edit_comment.js (line 34)
onclick(click clientX=0, clientY=0)index.php (line 1)
[Break on this error] editbox += '<input type="hidden" name="type" value="' + type + '" />';

Any help would be much appreciated.

Thanks in advance,

The14thGOD

david_kw
04-11-2007, 07:40 AM
It's quite possible I'm missing it but I don't see anything inherently wrong with that line. You'll probably need to post more. Perhaps the function where it is called (or the lines around it if it is not in a function) and the code where editbox and type are defined.

david_kw

The14thGOD
04-11-2007, 07:44 AM
function editText(target) {
//if not already editing
if (editActive == 0) {
//grab content
var content = document.getElementById(target).innerHTML;
var revertto = document.getElementById(target).innerHTML;

//create textarea box
var editBox = '<form name="editcomment" method="post">';
editBox += '<textarea name="text" cols="65" rows="3">';
editBox += content + '</textarea><br />';

//create submit button
editbox += '<input type="hidden" name="type" value="' + type + '" />';
editbox += '<input type="hidden" name="id" value="' + target + '" />';
editBox += '<input type="submit" value="Submit" onClick="setText(\'' + target + '\')">';
editBox += '<input type="submit" value="Cancel" onClick="cancel(\'' + target + '\')">';
editBox += '</form>';

//put textarea into div
document.getElementById(target).innerHTML = editBox;

//flag as editing
editActive = 1;

return false;
}
}

The14thGOD
04-11-2007, 07:49 AM
i just noticed it, editbox vs editBox, sorry :(

david_kw
04-11-2007, 08:18 AM
No problem. Glad you found it. :)

david_kw