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

textbox.width=textbox.width*0.85 Text Resize Control Help

6
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:20; width:200; font-size:12" />
[/HTML]

Thanks in advance for any help you can add.
Nov 30 '07 #1
4 5636
gits
5,390 Expert Mod 4TB
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
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 Expert Mod 4TB
hi ...

have a look at the following example:

[HTML]<script type="text/javascript">
function resize_tb(tb_id) {
var tb = document.getElementById('my_tb');
tb.style.width = tb.style.width.replace(/px$/, '') * 2 + 'px';
}
</script>
<body onload="resize_tb('my_tb');">
<input style="width:400px" 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
for(i=0; i<document.frmMain.elements.length; i++)
{
if(document.frmMain.elements[i].type=="text")
{
document.frmMain.elements[i].style.width=document.frmMain.elements[i].style.width * intWidthMultiplier;
}
}
}

I continue to get invalid arguement with this.....
The error is pointing to this line
document.frmMain.elements[i].style.width=document.frmMain.elements[i].style.width * intWidthMultiplier

the variable intWidthMultiplier 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
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...
2
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...
5
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...
2
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
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...
1
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...
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:
10
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...
0
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...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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,...

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.