Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > JS problem faced when field name has a dot

Reply
Thread Tools

JS problem faced when field name has a dot

 
 
Blue
Guest
Posts: n/a
 
      10-11-2006
The JS below will insert predefined text into the area text box when you
click on the smileys. This sample script is working fine.

But my problem is, in my PHP script, the "myfieldname" below is
"message.body". The dot in the field name is giving problem to the JS.

The JS stop working if it is:
document.myformname.message.body.value += ' ' + theSmilie + ' ';
document.myformname.message.body.focus();

How to go about this? I cannot change the field name.

==============================================
<script language="javascript">
<!--

function emoticon(theSmilie) {
document.myformname.myfieldname.value += ' ' + theSmilie + ' ';
document.myformname.myfieldname.focus();
}

//-->
</script>

</head>
<body>


<form name="myformname">
<textarea name="myfieldname" cols="48" rows="10"></textarea>

<a href="javascript:emoticon('')"><img src="gfx/icon_smile.gif""
border="0"></a>
<br>
<a href="javascript:emoticon('')"><img src="gfx/icon_biggrin.gif""
border="0"></a>
 
Reply With Quote
 
 
 
 
Lee
Guest
Posts: n/a
 
      10-11-2006
Blue said:
>
>The JS below will insert predefined text into the area text box when you
>click on the smileys. This sample script is working fine.
>
>But my problem is, in my PHP script, the "myfieldname" below is
>"message.body". The dot in the field name is giving problem to the JS.
>
>The JS stop working if it is:
>document.myformname.message.body.value += ' ' + theSmilie + ' ';
>document.myformname.message.body.focus();
>
>How to go about this? I cannot change the field name.



Next time, put a little thought into the field names.

document.myformmame.elements["message.body"].value ...

http://www.jibbering.com/faq/#FAQ4_25


--

 
Reply With Quote
 
 
 
 
Matt Kruse
Guest
Posts: n/a
 
      10-11-2006
Blue wrote:
> But my problem is, in my PHP script, the "myfieldname" below is
> "message.body". The dot in the field name is giving problem to the JS.
> The JS stop working if it is:
> document.myformname.message.body.value += ' ' + theSmilie + ' ';


http://www.javascripttoolbox.com/bes...#squarebracket

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com


 
Reply With Quote
 
Hal Rosser
Guest
Posts: n/a
 
      10-11-2006
you may have better luck accessing the form elements using index numbers:
document.forms[0].elements[x].value

hopethishelps


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
javascript validation for a not required field, field is onlyrequired if another field has a value jr Javascript 3 07-08-2010 10:33 AM
problem faced while using setContentType("Application/csv") Madni Java 2 01-04-2006 10:34 AM
problem faced while using setContentType("Application/csv") Madni Java 0 01-02-2006 01:02 PM
Dynamically resize visible text and append dot dot dot (like gmail subject lines.. ) how to question? jawolter@gmail.com Javascript 6 12-12-2005 04:09 PM
Request.Form("Field Name") Versus Request.QueryString("Field Name") John Davis ASP General 2 08-18-2003 05:00 AM



Advertisments