473,372 Members | 928 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,372 software developers and data experts.

textbox width

<html>
<body>
<form>
<input type="textbox" id="myTxt" value="what's my width?"
onClick="alert(this.width)">
</form>
</body>
</html>

how can I get a handle on the width of that textbox? Or can I at all?
Jul 23 '05 #1
7 14735
"Alex" <al******************@remove.this> wrote in message
news:Pz*******************@twister.rdc-kc.rr.com...
<html>
<body>
<form>
<input type="textbox" id="myTxt" value="what's my width?"
onClick="alert(this.width)">
</form>
</body>
</html>

how can I get a handle on the width of that textbox? Or can I at all?


Probbaly not what you want but you can set it.

<input type="textbox" style="width:100px" >
Jul 23 '05 #2
right, and i'm aware of that... how would you then--ever--be able to
determine the height of an object on a page?? not even when a stylesheet
style is set does it seem to work?!

ANY ideas???
"McKirahan" <Ne**@McKirahan.com> wrote in message
news:ke********************@comcast.com...
"Alex" <al******************@remove.this> wrote in message
news:Pz*******************@twister.rdc-kc.rr.com...
<html>
<body>
<form>
<input type="textbox" id="myTxt" value="what's my width?"
onClick="alert(this.width)">
</form>
</body>
</html>

how can I get a handle on the width of that textbox? Or can I at all?


Probbaly not what you want but you can set it.

<input type="textbox" style="width:100px" >

Jul 23 '05 #3
Alex wrote:
<input type="textbox" id="myTxt" value="what's my width?" onClick="alert(this.width)"> <snip> how can I get a handle on the width of that textbox? Or can I at all?


This works in my IE 6, Netscape 7.2, Firefox 1.0

function showwidth(){
t=document.getElementById('txt1');
alert(t.offsetWidth);
}

<input type="textbox" id="txt1" value="what's my width?">
Jul 23 '05 #4
Alex wrote:
right, and i'm aware of that... how would you then--ever--be able to
determine the height of an object on a page?? not even when a stylesheet
style is set does it seem to work?!

ANY ideas???


Did you try this approach:

d=document.getElementById(objectID);
alert(d.offsetHeight);

The first 2 links show browser support:

http://www.quirksmode.org/js/doctypes.html
http://www.evolt.org/article/documen...655/index.html
http://msdn.microsoft.com/workshop/a...ffsetwidth.asp

Mike
Jul 23 '05 #5
Alex wrote:
<html>
<body>
<form>
<input type="textbox" id="myTxt" value="what's my width?"
onClick="alert(this.width)">
</form>
</body>
</html>

how can I get a handle on the width of that textbox? Or can I at all?


<form action="">
<input type="textbox" id="myTxt" value="what's my width?"
onClick="
var msg;
var elem = this;

// IE method
if (elem.currentStyle) {
msg = elem.currentStyle['width'];

// W3C method
} else if (window.getComputedStyle) {
var compStyle = window.getComputedStyle(elem, '');
msg = compStyle.getPropertyValue('width');
} else {
msg = 'The methods I tried ain\'t '
+ 'supported by your browser.';
}

alert(msg)">
</form>

However, you will notice that IE very helpfully returns "auto" if
you haven't specified a width. Firefox gives a response in px.

Courtesty of:
<URL:http://www.oreillynet.com/pub/a/javascript/excerpt/JSDHTMLCkbk_chap5/index5.html>

--
Rob
Jul 23 '05 #6
suh-weet!!

Mike, that's spot-on EXACTLY what I was looking for. thanks so much! Do you
know of a good JS reference?

thanks again!
"mscir" <ms***@yahoo.com> wrote in message
news:11*************@corp.supernews.com...
Alex wrote:
right, and i'm aware of that... how would you then--ever--be able to
determine the height of an object on a page?? not even when a stylesheet
style is set does it seem to work?!

ANY ideas???


Did you try this approach:

d=document.getElementById(objectID);
alert(d.offsetHeight);

The first 2 links show browser support:

http://www.quirksmode.org/js/doctypes.html
http://www.evolt.org/article/documen...655/index.html
http://msdn.microsoft.com/workshop/a...ffsetwidth.asp

Mike

Jul 23 '05 #7
Alex wrote:
... Do you know of a good JS reference?


Google for "JavaScript 1.5 reference" and you'll find lots of them.

http://www.programmershelp.co.uk/javascriptref.php
http://www.byteshift.de/javascript-1415/CoreGuideJS15/
http://synchro.net/docs/js/ref/ix.html
http://www.croczilla.com/~alex/refer...avascript_ref/

I learned a LOT (including offsetWidth) from this newsgroup. When I run
into problems I use Google, and search this newsgroup to see if similar
problems have been solved here.

Also, please don't top post, it throws off the Q&A flow.
Good Luck,
Mike
Jul 23 '05 #8

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

Similar topics

4
by: Rodrigo DeJuana | last post by:
Howdy, I'm new to this .net stuff and really have little to no training. Im trying to create a new page for a web form, so i have been pretty much jsut coping code. I having some issue with...
1
by: Shilpi Chaudhry | last post by:
I have a forloop which I use to create textboxes - but unfortunately all of them have the same ids - I need to assign different ids to these textboxes creeated in the loop so that I can retrieve...
2
by: Calvin KD | last post by:
Hi everyone, I have a number of textboxes, lined up in a html table. I have split the table into different columns. The column widths are all relative, that is, % rather pixels or points so that...
10
by: aarepasky | last post by:
I am using ASP Web 2005 express. I created the user control below and I am listing the html code. I have 2 textboxes. One is txtCompanyName. The main page has 2 panels on it and a button. ...
8
by: Filipe Marcelino | last post by:
Hi, I'm trying to create a textbox inheriting from the standard textbox. I would like to: 1. repaint the textbox border; 2. define a color for that border; Till now I made this:
0
by: mamun | last post by:
Hi All, I have the following situation. I have 10 rows in a form. In each row there are six textbox controls. The users can enter any number of rows of records (either none or upto 10). I...
0
by: Jacob Donajkowski | last post by:
Once the user logs in I want to have the users switch from the Roster View to the Profile View and enter their profile infomation and save it. Then the next time they login and go to the Profile...
0
by: sjickells | last post by:
Hi I am having a problem using asp:TextBox's in a transparent table. I have a background image on the page and a table in the middle of the page. I have set the background colour of the table...
0
KalariaNitya
by: KalariaNitya | last post by:
Hello, could anybody help me? i have gridview, inside gridview i have one Update button & textbox update button update the quantity entered in textbox. i want to update the quantity on textbox on...
2
by: mrutyunjaya | last post by:
hello, i have two textbox column and one button control in gridvie when i click button it will ask plese enter price in first textbox . when enter values it is asking again. how to pass...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: 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
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...

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.