473,799 Members | 2,822 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 5658
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
9472
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
8405
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
1735
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
3691
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
2849
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
2483
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
9689
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
9550
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
9085
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7573
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
6811
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
5469
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...
0
5597
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4148
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
2942
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.