Shoutbox

JavaScript problem - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: JavaScript problem (/showthread.php?tid=53567)

JavaScript problem by DragonX on 12-03-2005 at 09:15 PM

Me again ;) this time i'm truely lost, i've searched google and found exactly what i need to do, but when i do it, it doesn't work. It goes as such..

code:
function quote(id) {
  var username = eval("document.quote.q"+id+".value");
  document.inputform.message.value += quote\r\n;
  document.inputform.message.focus();
}

code:
<form method='post' name='inputform' onsubmit='return checkForm(this)'>
    <textarea name='message' rows='10' cols='50'</textarea>
</form>


Now all works fine, i can get the info out of qid and show it in an alert fine, my problem comes with the other two js statements.

1. It won't put the text in the textarea.
2. when doing focus(), IE says "Object doesn't support this property method"

So am at a loss right now :S
RE: JavaScript problem by WDZ on 12-04-2005 at 07:24 AM

quote:
document.inputform.message.value += quote\r\n;
What is "quote" supposed to be? I don't see any variable by that name defined. Also, \r\n is a string, so it needs to be enclosed in quotation marks. Something like this would probably work...

document.inputform.message.value += username+"\r\n";
quote:
<textarea name='message' rows='10' cols='50'</textarea>
You're missing a ">" in there.
RE: JavaScript problem by ShawnZ on 12-04-2005 at 01:30 PM

Also, use IDs and document.getElementById() instead of NAME.


RE: JavaScript problem by -dt- on 12-04-2005 at 01:42 PM

quote:
Originally posted by ShawnZ
Also, use IDs and document.getElementById() instead of NAME.
:P why.... he may want to submit the form and its easier to do it like that?
and then i hear you shout XPCNativeWrappers well he could just use
document.forms.namedItem("inputform").elements.namedItem("message").value
RE: JavaScript problem by DragonX on 12-04-2005 at 02:59 PM

oops, ok, here that block of code again

code:

function quickquote(pid) {
  if(qqsel != "" && qqsel.indexOf("[quote]") == -1) {
    var quote = qqsel;
  } else {
    var quote = eval("document.quickquote.qq"+pid+".value");
  }
  qqsel = "";
  var username = eval("document.quickquote.qq"+pid+".value");
  alert(quote);
  document.quickreplyform.message.value += "[quote="+username+"]"+quote+"[/quote]\r\n";
  document.quickreplyform.message.focus();
}


this is all in a html .tpl file btw.