473,687 Members | 2,962 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(inputo bject) {
var obj=(inputobjec t);
document.main.o jb().value="hel lo";
document.main.a aa.focus();
}
----------------
<form name="main">
<input type="text" value="aaa" name="boxaaa">
<input type="text" value="bbb" name="boxbbb">
<input type="button" value="clickme" onclick="clearB ox(aaa)">
<input type="button" value="clickme" onclick="clearB ox(bbb)">
</form>
Jul 20 '05 #1
2 3823
Ben Dover - Mental Patient 0057 <Be*******@psyc hiatric-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(inputo bject) {
var obj=(inputobjec t);
document.main.o jb().value="hel lo";
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="clearB ox(aaa)"> onclick="clearB ox('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="clearB ox(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(inputo bject) {
var obj=(inputobjec t);
document.main[inputobject].value="";
document.main[inputobject].focus();
}
in the body:
<form name="main" >
<INPUT TYPE="TEXT" VALUE="hellowor ld" NAME="login">
<a href="#" onclick="clearB ox('login');">c lear login</a>

<INPUT TYPE="TEXT" VALUE="hellowor ld" NAME="password" >
<a href="#" onclick="clearB ox('password'); ">clear password</a>

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

Lasse Reichstein Nielsen wrote:

Ben Dover - Mental Patient 0057 <Be*******@psyc hiatric-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(inputo bject) {
var obj=(inputobjec t);
document.main.o jb().value="hel lo";


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="clearB ox(aaa)">

onclick="clearB ox('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="clearB ox(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
10084
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 application that I'm trying to build. I should add that i am a very new user to VB.NET and as such am very ignorant so please excuse this. Many thanks for any assistance. regards
3
2167
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() when that event is 'going on' the load control happens but the values are not yet 'filled in' They are filled in only -when- the pageload event has
5
1039
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 that will allow them to edit the products within that list. I was thinking of writing using a DataReader and spitting the values out into textboxes. The only problem is that I won't know beforehand what the textboxes would be called. In the past...
9
7036
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 to VB, plus the address bar would show something like this: www.somethinghere?id=3 and if you change number 3 from the address bar to (for example) 34 or 71 you would get different page with the same formatting like I.e: www.somethinghere?id=34...
6
1494
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 subroutine on postback. To me it seems like the button click event looks for a client script instead of going to the aspx codepage and execute the sub there. The same thing happens with textboxes, where I programatically add
5
1958
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 some textboxes (dynamically added). I know I could move it around with CSS but I want to move towards an accessible site that will display forms in the right order without CSS. Regards, Chris.
1
8405
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 textbox,if i click that button once again display another textbox.if i click 10 times it will display 10 textboxes. so i want code for displaying textboxes dynamically using javascript.
2
1846
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 textboxes not visible.anybody help me to solve this problem.......
1
2313
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 dynamically.but here i put this controls in a panel.here my problem is all controls are placed in the same position. but my requirement is all textboxes are arranged one by one.iam trying with this using tablelayoutpanel.but i dont know how to dynamically...
0
1504
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 an update panel. I store the ID for the generated textboxes in the Viewstate, which I use in the Panels' INIT eventhandler to go ahead and instantiate the textboxes once again every postback. I use the, in my opinion, old mechanism of retreiving
0
8590
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8527
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8947
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8783
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6451
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5806
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4542
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2961
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
1947
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.