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

dynamically set textboxes

i want to be able to dynamically set different text boxes depending on
the button pressed.
i was hoping obj() can "become" object "aaa" or "bbb", but it's not
working.

function clearBox(inputobject) {
var obj=(inputobject);
document.main.ojb().value="hello";
document.main.aaa.focus();
}
----------------
<form name="main">
<input type="text" value="aaa" name="boxaaa">
<input type="text" value="bbb" name="boxbbb">
<input type="button" value="clickme" onclick="clearBox(aaa)">
<input type="button" value="clickme" onclick="clearBox(bbb)">
</form>
Jul 20 '05 #1
2 3800
Ben Dover - Mental Patient 0057 <Be*******@psychiatric-center.Bellevue-Hospital.com> writes:
i want to be able to dynamically set different text boxes depending on
the button pressed. i was hoping obj() can "become" object "aaa" or "bbb", but it's not
working.

function clearBox(inputobject) {
var obj=(inputobject);
document.main.ojb().value="hello";
From the FAQ <URL:http://jibbering.com/faq/#FAQ4_39>

document.forms['main'].elements[inputobject].value="hello";

(I prefer to always use the forms and elements collections)

This also requires that the remaining code is correct :
<input type="text" value="aaa" name="boxaaa">
<input type="text" value="bbb" name="boxbbb">
<input type="button" value="clickme" onclick="clearBox(aaa)"> onclick="clearBox('aaa')"
You want to send a string, not the value of the possibly non-existing
global variable called "aaa".
<input type="button" value="clickme" onclick="clearBox(bbb)">


Ditto here.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
just want to share with everyone what I put together:
in the head:

function clearBox(inputobject) {
var obj=(inputobject);
document.main[inputobject].value="";
document.main[inputobject].focus();
}
in the body:
<form name="main" >
<INPUT TYPE="TEXT" VALUE="helloworld" NAME="login">
<a href="#" onclick="clearBox('login');">clear login</a>

<INPUT TYPE="TEXT" VALUE="helloworld" NAME="password">
<a href="#" onclick="clearBox('password');">clear password</a>

etc...
</form>
have fun folks!

Lasse Reichstein Nielsen wrote:

Ben Dover - Mental Patient 0057 <Be*******@psychiatric-center.Bellevue-Hospital.com> writes:
i want to be able to dynamically set different text boxes depending on
the button pressed.

i was hoping obj() can "become" object "aaa" or "bbb", but it's not
working.

function clearBox(inputobject) {
var obj=(inputobject);
document.main.ojb().value="hello";


From the FAQ <URL:http://jibbering.com/faq/#FAQ4_39>

document.forms['main'].elements[inputobject].value="hello";

(I prefer to always use the forms and elements collections)

This also requires that the remaining code is correct :
<input type="text" value="aaa" name="boxaaa">
<input type="text" value="bbb" name="boxbbb">
<input type="button" value="clickme" onclick="clearBox(aaa)">

onclick="clearBox('aaa')"
You want to send a string, not the value of the possibly non-existing
global variable called "aaa".
<input type="button" value="clickme" onclick="clearBox(bbb)">


Ditto here.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'

Jul 20 '05 #3

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

Similar topics

2
by: Briand | last post by:
In my previous posting I failed miserably, to give enough information to get my difficulty apparent. So to start again. I want to create textboxes dynamically in VB.NET. This is not a web...
3
by: Egbert Nierop \(MVP for IIS\) | last post by:
Hi, I have a complex asp.net 1.1 program that dynamically needs to load controls (LoadControl) The textboxes etc inside these controls keep viewstate and values but not within Page_Load() ...
5
by: Will Lastname | last post by:
I'm working on administration panel that will ultimately allow the client to edit products in a collection. Each ProjectList can have multiple products within it. I was asked to create something...
9
by: netasp | last post by:
hi all, how can I populate one aspx form when page is loading based on page ID? for example: loading page A (to search for VB code) would display labels and texboxes, dropdown lists all related...
6
by: Bjorn Sagbakken | last post by:
Hello In VS2005: I am adding buttons and textboxes dynamically into a table, that also dynamically expands. So far, so good, actually very nice. But I am having trouble starting the desired...
5
by: Chris | last post by:
I have a page with mixture of static and dynamically added controls is there any way of controlling the order which they are added to the page. My submit button (statically added) appears before...
1
by: Sirisha | last post by:
Hi, I want javascript for displaying multiple textboxes dynamically. ADD-this is button. if i click button first time it will display 1 textbox and if i click 2nd time it will display another...
2
by: osakthivel | last post by:
hello sir, I have one problem.I want to createtexboxes dynamically using javascript when textbox onblur event.after creating textboxes if i submit the form the dynamically created...
1
by: bharathi228 | last post by:
hi, iam doing a windows application.i have a requirement like to create labels and textboxes dynamically at runtime.iam giving input as number of labels,and textboxes then it will created...
0
by: rvdnieuwenhuizen | last post by:
Hi, The problem I cannot seem to solve: I have a page with a button control. In the On_Click eventhandler I dynamically add one TextBox each time the button is clicked. I add the textboxes to...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.