473,387 Members | 1,790 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,387 software developers and data experts.

querying textfields outside of forms...

Hi,

I am trying to query the value of a textfield outside of a form but
with no success so far... the reason why I am not using a form is that
there seams to be an annoying issue with hitting the [Enter] key (at
least in Mozilla) when there is only one textfield in the form... the
[Enter] key seams to trigger some type of a submit... but when the
textfield is defined outside of a form this is not an issue... However
I don't know how to access the value for the textfield outside the
form... see example below...

any help is greatly appreciated...

Thanks,
Markus.

<html>
<script language="JavaScript">
function update() {
var ctrls_doc = document;

ctrls_doc.writeln("<html>");
ctrls_doc.writeln("<body>");

ctrls_doc.writeln("<form name='controls' >");
ctrls_doc.writeln("<table cellpadding='2' cellspacing='2'
border='1' height='100%'>");
ctrls_doc.writeln("<td align='center' valign='center'>");
ctrls_doc.writeln("Inside FORM: <input type='text'
name='OpsName'>");
ctrls_doc.writeln("</td>");
ctrls_doc.writeln("</tr>");
ctrls_doc.writeln("</table>");
ctrls_doc.writeln("</form><br>");

ctrls_doc.writeln("Outside FORM: <input type='text'
name='OpsName2'><br><br>");

ctrls_doc.writeln("<input type='button' name='CheckMe'
value='Check ME' onclick='check()'>");

ctrls_doc.writeln("</body>");
ctrls_doc.writeln("</html>");

ctrls_doc.close();
}

function check()
{

alert("FIRST: " + window.document.controls.elements.OpsName.value+
"\n" +
"SECOND: " + window.document.OpsName2);

}

update()
</script>

</html>
Jul 20 '05 #1
1 1989
swp
try using something like this to get around the "[Enter]" problem,
which seems to be the heart of your issue.

as always, be careful of line wrapping...
================================================== ===========================
function tabOnEnter(field, evt) {
var keyCode = document.layers ? evt.which : document.all ?
evt.keyCode : evt.keyCode;
if (keyCode != 13)
return true;
else {
getNextElement(field).focus();
return false;
}
}

use it like this:
<input name=svar size=35 value='' OnKeyDown="return tabOnEnter(this,
event);">
================================================== ===========================

hope this helps,

swp

mb****@pdi.com (Markus) wrote in message news:<3e*************************@posting.google.c om>...
Hi,

I am trying to query the value of a textfield outside of a form but
with no success so far... the reason why I am not using a form is that
there seams to be an annoying issue with hitting the [Enter] key (at
least in Mozilla) when there is only one textfield in the form... the
[Enter] key seams to trigger some type of a submit... but when the
textfield is defined outside of a form this is not an issue... However
I don't know how to access the value for the textfield outside the
form... see example below...

any help is greatly appreciated...

Thanks,
Markus.

<html>
<script language="JavaScript">
function update() {
var ctrls_doc = document;

ctrls_doc.writeln("<html>");
ctrls_doc.writeln("<body>");

ctrls_doc.writeln("<form name='controls' >");
ctrls_doc.writeln("<table cellpadding='2' cellspacing='2'
border='1' height='100%'>");
ctrls_doc.writeln("<td align='center' valign='center'>");
ctrls_doc.writeln("Inside FORM: <input type='text'
name='OpsName'>");
ctrls_doc.writeln("</td>");
ctrls_doc.writeln("</tr>");
ctrls_doc.writeln("</table>");
ctrls_doc.writeln("</form><br>");

ctrls_doc.writeln("Outside FORM: <input type='text'
name='OpsName2'><br><br>");

ctrls_doc.writeln("<input type='button' name='CheckMe'
value='Check ME' onclick='check()'>");

ctrls_doc.writeln("</body>");
ctrls_doc.writeln("</html>");

ctrls_doc.close();
}

function check()
{

alert("FIRST: " + window.document.controls.elements.OpsName.value+
"\n" +
"SECOND: " + window.document.OpsName2);

}

update()
</script>

</html>

Jul 20 '05 #2

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

Similar topics

3
by: frizzle | last post by:
Hi there, I'm building a multi-language PHP/mySQL -site. I'm also building a CMS for the site. There are 5 languages. In the CMS fields for e.g. english bodytext are called (id=)...
1
by: Ed | last post by:
Hi, I have an html page with a div element within a form for dynamically creating textfields. The problem is when I click a link on the page, or the submit button, then click the back button,...
4
by: Stewart Allen | last post by:
I'm trying to filter a table that has 2 date fields, the first date will always have a value but the second will only occasionally has a value. Each date field also has a corresponding text field...
6
by: anirban.anirbanju | last post by:
hi there, i've some serious problem to add rows dynamically in a table. my table contains 5 cell. | check | from_value | to_value | color_text | color_value |...
4
by: monomaniac21 | last post by:
hi all im wondering is there a better db than mysql for perfoming queries to search textfields for the occurence of a string value? for example does oracle have greater functionality is this...
0
by: chandutp | last post by:
hi i am new to this forum can i populate datagrid items of asp page to another asp page having textfields. in this datagrid userId is the index key by which it referenced.and i am using edit...
1
by: eureka | last post by:
Hi folks, I am working on a webapplication using Jsp and JS. On my main Jsp(Jsp1) I have a table which is created dynamically inside a <divand contains all the backend-table's records as rows,...
2
by: f3dde | last post by:
Hi there, I have a question about forms in MS Access.. Is it possible in any way at all, to add info in 2 textfields and save it as 1 record. Detail: I have a record with 3 fields....
1
by: JackRbt | last post by:
I'm using an array to submit textfields. Something like: <input name="tf">... <input name="tf">... <input name="tf">... so that I can iterate through the answers easily. I just want to be...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.