473,385 Members | 1,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

JS problem faced when field name has a dot

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(':smile:')"><img src="gfx/icon_smile.gif""
border="0"></a>
<br>
<a href="javascript:emoticon(':grin:')"><img src="gfx/icon_biggrin.gif""
border="0"></a>
Oct 11 '06 #1
3 5441
Lee
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
--

Oct 11 '06 #2
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
Oct 11 '06 #3
you may have better luck accessing the form elements using index numbers:
document.forms[0].elements[x].value

hopethishelps
Oct 11 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: mahesh j k | last post by:
Table1: RouteID RDate Direction RTime Employee_ID ArrTime R1 6/15/2005 Pick 6/15/2005 9:30:00 AM 1430 6/15/2005 8:12:00 AM R2 6/15/2005 Pick 6/15/2005 3:00:00...
7
by: meaneyedcat | last post by:
When I call addField(), my table appears to be populated correctly with a new row in the table with all the required fields. However, when I call delete row on any new rows that have been created,...
3
by: Pavils Jurjans | last post by:
Hello, I have bumped upon this problem: I do some client-side form processing with JavaScript, and for this I loop over all the forms in the document. In order to identify them, I read their...
7
by: CharlesEF | last post by:
Hi All, I have run into another problem that is eating my lunch. Should be simple but I am having one heck of a time. Please look at this SELECT statement: SELECT FROM States WHERE ] =...
4
by: Tomas Rivas | last post by:
I am trying to validate an xml file and schema and when I am trying to validate I am getting the following error. I have been trying to come out with a solution but I have failed so far. The...
0
by: Deep Purple | last post by:
I started with the following error... ------------------------------------------------------- An error occured while loading the schema with TargetNamespace 'http://www.w3.org/2001/XMLSchema'...
2
by: Charles Law | last post by:
I have a complex object that I am serializing, and I would like to omit elements that have a default value. For example, if I have a class as follows Public Class Test Private m_Name As...
7
by: Mary | last post by:
I have a student who has a hyphenated first name. If I concatenate the name like this: StudentName:( & ", " & ), it works as expected. If, however, I try to get the first name first by...
7
by: Evanescent | last post by:
Hi guys, as the title suggests, I'm facing some problems with the report. I have a form (createInvoiceForm) whereby the user can enter the invoice's details and then click on the Add New Record...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.