Closed Thread Icon

Topic awaiting preservation: JS Problem (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=8745" title="Pages that link to Topic awaiting preservation: JS Problem (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: JS Problem <span class="small">(Page 1 of 1)</span>\

 
Moon Shadow
Paranoid (IV) Inmate

From: Rouen, France
Insane since: Jan 2003

posted posted 07-08-2003 10:07

On my website, I want that when I click on a smiley, a certain code is added to a message area. Go here if you want to see what I mean. For now, it works very well. The code used is the following :

Before the image tags of the smilies, there is an a tag like this for example : <a href="javascript:setsmiley(' ( ')">

Here is the function associated :

function setsmiley(sm) {
document.sb.Message.value = document.sb.Message.value + sm;
}

It searchs in my page the form called "sb", and in the text area whose name is "Message" is adds the smiley. However, I have a little problem due to XHTML. For now, the form "sb" is set with name="sb". And the problem is that I need it to be id="sb" to be compliant. I already tried, but when I set it to id, it seems that the Javascript code isn't working anymore.

So, I tried a Javascript code by Dreamweaver MX :

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_changeProp(objName,x,theProp,theValue) { //v6.0
var obj = MM_findObj(objName);
if (obj && (theProp.indexOf("style.")==-1

HZR
Bipolar (III) Inmate

From: Cold Sweden
Insane since: Jul 2002

posted posted 07-08-2003 12:09
code:
function setsmiley(sm) {
document.getElementById("Message").value += sm;
}


And change the "name" attribute to "id" in the textarea tag.


[This message has been edited by HZR (edited 07-08-2003).]

Moon Shadow
Paranoid (IV) Inmate

From: Rouen, France
Insane since: Jan 2003

posted posted 07-08-2003 15:28

I had to change it to :

function setsmiley(sm) {
document.getElementById("sb").Message.value += sm;
}

But thanks a lot HZR, it worked

« BackwardsOnwards »

Show Forum Drop Down Menu