Click here to get back home

text field besides the input tag

 HomeNewsGroups | Search | About
 comp.infosystems.www.authoring.html    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
text field besides the input tag David Tay 05-26-2008
Get Chitika Premium
Posted by David Tay on May 26, 2008, 1:11 pm
Please log in for more thread options
Is there a text field tag with a value parameter that I can refer to
with Javascript besides the input tag?

What I have been doing is using Ajax and PHP to pull data out of a
database. Then with Javascript I have been filling the value of an
input text field with with that data. The input text field has its
border styled off so it looks just like text.

Is there a cleaner way of doing this?

Posted by Adrienne Boswell on May 26, 2008, 8:25 pm
Please log in for more thread options
writing in news:0b0f7df5-6989-4221-bddf-7878eb4f5f92
@m45g2000hsb.googlegroups.com:

> Is there a text field tag with a value parameter that I can refer to
> with Javascript besides the input tag?
>
> What I have been doing is using Ajax and PHP to pull data out of a
> database. Then with Javascript I have been filling the value of an
> input text field with with that data. The input text field has its
> border styled off so it looks just like text.
>
> Is there a cleaner way of doing this?
>

<form method="post" action="action">
<div>
<label for="field" id="field1">Field</label> <input type="text"
name="name" id="field" value="recordset.value">
<input type="submit" value="Submit">
</div>
</form>

You can style the label element and refer to it in script.

--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share


Posted by Harlan Messinger on May 27, 2008, 7:53 am
Please log in for more thread options
David Tay wrote:
> Is there a text field tag with a value parameter that I can refer to
> with Javascript besides the input tag?
>
> What I have been doing is using Ajax and PHP to pull data out of a
> database. Then with Javascript I have been filling the value of an
> input text field with with that data. The input text field has its
> border styled off so it looks just like text.
>
> Is there a cleaner way of doing this?

It's tricky to respond to a person who says what he is doing rather than
stating what he is trying to accomplish--*why* he is doing it. I'm
inferring that (a) you want the data to appear as text on the screen and
(b) you also want it to be submitted along with other data from a form.

The proper approach is (a) to display it as ordinary text where you want
it to appear as ordinary text and (b) also to include a *hidden* input
element on the form with the required data as its value.

Posted by David Tay on May 27, 2008, 2:11 pm
Please log in for more thread options
What I was trying to do was to display rows from a database using
Ajax. In order to do that I had to create an input field whose value I
would assign with Javascript. For example:

First name: <input name="firstName" value="" style="border-width:
0px"><br/>
Last name: <input name="lastName" value="" style="border-width:0px">

Now in Javascript, I would do the following:

if (xmlHttp.readyState==4){
var names = new Array();
names = xmlHttp.responseText.split("&");
var firstName = document.getElementsByName("firstName");
var lastName = document.getElementsByName("lastName");
firstName[0].value=names[0];
lastName[0].value=names[1];
}

Do you understand now?

On May 27, 7:53 am, Harlan Messinger
> David Tay wrote:
> > Is there a text field tag with a value parameter that I can refer to
> > with Javascript besides the input tag?
>
> > What I have been doing is using Ajax and PHP to pull data out of a
> > database. Then with Javascript I have been filling the value of an
> > input text field with with that data. The input text field has its
> > border styled off so it looks just like text.
>
> > Is there a cleaner way of doing this?
>
> It's tricky to respond to a person who says what he is doing rather than
> stating what he is trying to accomplish--*why* he is doing it. I'm
> inferring that (a) you want the data to appear as text on the screen and
> (b) you also want it to be submitted along with other data from a form.
>
> The proper approach is (a) to display it as ordinary text where you want
> it to appear as ordinary text and (b) also to include a *hidden* input
> element on the form with the required data as its value.


Posted by Harlan Messinger on May 27, 2008, 4:16 pm
Please log in for more thread options
David Tay wrote:
[top-posting corrected]
> On May 27, 7:53 am, Harlan Messinger
>> David Tay wrote:
>>> Is there a text field tag with a value parameter that I can refer to
>>> with Javascript besides the input tag?
>>> What I have been doing is using Ajax and PHP to pull data out of a
>>> database. Then with Javascript I have been filling the value of an
>>> input text field with with that data. The input text field has its
>>> border styled off so it looks just like text.
>>> Is there a cleaner way of doing this?
>> It's tricky to respond to a person who says what he is doing rather than
>> stating what he is trying to accomplish--*why* he is doing it. I'm
>> inferring that (a) you want the data to appear as text on the screen and
>> (b) you also want it to be submitted along with other data from a form.
>>
>> The proper approach is (a) to display it as ordinary text where you want
>> it to appear as ordinary text and (b) also to include a *hidden* input
>> element on the form with the required data as its value.
> What I was trying to do was to display rows from a database using
> Ajax. In order to do that I had to create an input field whose value I
> would assign with Javascript. For example:
>
> First name: <input name="firstName" value="" style="border-width:
> 0px"><br/>
> Last name: <input name="lastName" value="" style="border-width:0px">
>
> Now in Javascript, I would do the following:
>
> if (xmlHttp.readyState==4){
> var names = new Array();
> names = xmlHttp.responseText.split("&");
> var firstName = document.getElementsByName("firstName");
> var lastName = document.getElementsByName("lastName");
> firstName[0].value=names[0];
> lastName[0].value=names[1];
> }
>
> Do you understand now?
>
No, you haven't bothered to explain why these items need *both* (a) to
look like text and yet (b) function is input fields. The code you have
seems to accomplish what it is you want superficially, yet you asked
your question, so I'm trying to figure out what your underlying goal is
that might lead one to look for a different approach.

Similar ThreadsPosted
Dynamic width of a text input field in a form November 8, 2005, 6:35 am
can't get text field to align with textarea field March 9, 2005, 11:09 am
focus on a input field January 11, 2005, 2:18 am
Can an input field have a blank name? September 5, 2005, 8:29 pm
Right align content of field September 27, 2006, 3:43 am
Option Select + input field in one October 3, 2007, 8:18 pm
bad position of autocomplete list of input field May 17, 2005, 2:28 pm
Adjusting Input field size (height) September 9, 2006, 1:27 am
How to align text label and input field's text ? June 11, 2007, 6:10 am
Cursor in the beginning of text field. March 26, 2005, 7:20 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap