473,811 Members | 2,240 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

textbox.width=t extbox.width*0. 85 Text Resize Control Help

6 New Member
I am trying to develop a resize module i can include on my pages that calculates the size of input fields based on the screen resolution...
I can already detect the screen resolution, and i have the width / height multiplier for every resolution i need to support... my problem is this...


I want the include file to be totally universal so heres my plan
I will use CSS styles to set the current text box size... i want the javascript to then detect the screen size and apply the correct multiplier to the textbox size...

Where i run into issues is getting the current textbox size and adding it to itself, it seems i cannot use the current textbox size because the javascript is loading before the text boxes themselves...

I am triggering this java on the BODY ONLOAD event....

Expand|Select|Wrap|Line Numbers
  1. frmMain.txtLogin.style.width=frmMain.txtLogin.style.width*intWidthMultiplier
the input box would be coded like this

[HTML]<input type=text name=txtLogin style="height:2 0; width:200; font-size:12" />
[/HTML]

Thanks in advance for any help you can add.
Nov 30 '07 #1
4 5662
gits
5,390 Recognized Expert Moderator Expert
hi ...

welcome to TSDN ...

in case you call the script onload the textbox is ready to use and to be manipulated ...

but i think you have to add units to the width-value ...

Expand|Select|Wrap|Line Numbers
  1. text_box_reference.style.width = your_width + 'px';
note: the retrieved value should have that unit already, so you have to strip the value out of that before using math-operations :)

kind regards

ps: you should add the units too in the elements style-declaration ...
Nov 30 '07 #2
DeanJo
6 New Member
Im not familiar with units i will have to research these, i am executing the java function on Body Onload, when i try to use this code

Expand|Select|Wrap|Line Numbers
  1. frmMain.txtLogin.style.width=frmMain.txtLogin.style.width*intWidthMultiplier
then it errors stating "Invalid arguement"
Dec 1 '07 #3
gits
5,390 Recognized Expert Moderator Expert
hi ...

have a look at the following example:

[HTML]<script type="text/javascript">
function resize_tb(tb_id ) {
var tb = document.getEle mentById('my_tb ');
tb.style.width = tb.style.width. replace(/px$/, '') * 2 + 'px';
}
</script>
<body onload="resize_ tb('my_tb');">
<input style="width:40 0px" type="text" id="my_tb" name="test" value="test"/>
</body>
[/HTML]
the invalid arg error should come from another line of your code since the one you posted has no arguments?

kind regards
Dec 1 '07 #4
DeanJo
6 New Member
for(i=0; i<document.frmM ain.elements.le ngth; i++)
{
if(document.frm Main.elements[i].type=="text")
{
document.frmMai n.elements[i].style.width=do cument.frmMain. elements[i].style.width * intWidthMultipl ier;
}
}
}

I continue to get invalid arguement with this.....
The error is pointing to this line
document.frmMai n.elements[i].style.width=do cument.frmMain. elements[i].style.width * intWidthMultipl ier

the variable intWidthMultipl ier during my tests has a value of 0.050
Dec 3 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
9473
by: Ronald S. Cook | last post by:
Hi all, I have an ASP.NET DataGrid wherein there is an edit link for each row. Upon clicking the link, certan fields in that row display in text boxes so that they may be edited. I would like some textboxes to be wider, some narrower. By default, they are all the same pre-defined width. Does anyone know how I can do this? Thanks very much,
2
8407
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when submitting the form to update the database. The server doesn't have the client side value any more. It seems to me that as I begin to write the client side javacript code for form validation and client side editing capabilities in order to save...
5
1736
by: hanolo | last post by:
Does anyone ever see this happen. I build a form with couple of textbox server control. When user inputs character ` in there, after form post back, the textbox become a line of string such as <INPUT id=_txtName style="WIDTH: 70%" value=` name=_txtName>. I can filter out ` from the inputs, but it seems like a microsoft bug to me.
2
19877
by: Mamatha | last post by:
Hi I want to add an icon to the textbox's text. I don't know how to display icon in textbox in VB.NET. If any one knows please let me know. Thanks in advance. Mamatha
9
3693
by: Aaron Smith | last post by:
I am creating a subclassed text box. I want to have a button inside the tetbox. That was the easy part. The part I can't figure out, is how you set the area for the text? If you type a string it will go underneath the button instead of stopping at the button and doing it's normal wrap functionality where it pushes the text off the one side of the textbox... How do you tell it to only use a certain area for text? Aaron -- ---
1
2850
by: ramhog | last post by:
Hello all, I am trying to resize a textbox to exactly fit the contents. The method I am using gets it close but it is just a little bit too small. Could someone tell me where I am going wrong here please? /* SYSTEM GENERATED FOR THE TEXTBOX */ // // txt // this.txt.BorderStyle = System.Windows.Forms.BorderStyle.None;
8
5096
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:
10
2484
by: garyusenet | last post by:
I have a multiline textbox. The size of the text box should be 75 characters wide, and 5 lines in height like this: - <---75 characters--> <---75 characters--> <---75 characters--> <---75 characters--> <---75 characters-->
0
986
by: sagardeshmukh310 | last post by:
using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls;
0
9607
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
10652
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10395
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...
1
10408
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10137
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
7673
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
6895
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
5561
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4346
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

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.