Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem displaying the formatted field

Status
Not open for further replies.

msng

Programmer
Oct 14, 2003
27
0
0
US
If I want to display a certain field in a formatted form when the page is displayed, on what event can I do this.

e.g. I have the text box for phone number on my Edit form. I have written a javascript to format the phone number. However, when the Edit form is displayed, I want to display the phone number in a formatted form. On what event of the <input>tag can I call the javascript for formatting the phone, so that when the Edit form is displayed, it shows the phone in a formatted form.

Please help.

Thanks.
 
You can put the formatting code in a separate function first. The in the body tag:

<script... >
function FormatPage() {
FormatPhone(home_phone);
FormatPhone(business_phone);
FormatSomethignElse();
}
</script>

<body onLoad="FormatPage()">


If you don't want to touch the Body tag, you can also just include a snippet at the end of the HTML:

<script ...>
FormatPage();
</script>
 
Thedrider is right.. but sometimes that does not work.. I've had it work several times in a row and then the page will load and... nothing..

I like to put in an image and add an onload statement..

That may or may not work for you..

Javascript is not predictable.. For instance I needed to resize rapidly changing images on the fly one time.. and the site was too busy to bother with cfx_image and the like so I used a javascript and put onload in the resize..

Problem was, sometimes the image would be stuck in cache and wouldn't resize or it just flat refused to resize on initial image load having never seen the image before.

And also, some people do turn off javascript.. So if you're doing it just to make the number look nice, that's one thing, if you're doing it for a programming reason, don't rely on it..

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top