/    Sign up×
Community /Pin to ProfileBookmark

Creating an info box on my form

Hi can anyone offer me any help/guidance with a small issue that I am currently having. I have a form on my page and what i want to do is display specific info/text in an info box on the form when a user is at a specific input field on my form.

my basic form is as follows.

<form>
<table summary=”whatever”>
<tr>
<td>PIN</td>
<td><input type=”text” name=”pin” value=”” size=”20″></td>
</tr>
<td>Phone</td>
<td><input type=”text” name=”phone” value=”” size=”20″></td>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Info Box</td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan=”2″><input type=”text” name”infobox” value=”” size=”20″><td>
</tr>
</table>
</form>

So what i want is when a user clicks on the Pin field “Please enter your personal PIN number in the box, this can be found in your registration email” and when on the phone field it displays “Please enter your phone number eg 03212 223478”

Kind regards
guzzer

to post a comment
JavaScript

9 Comments(s)

Copy linkTweet thisAlerts:
@buntineJul 19.2004 — Due to the fact that ASP is a server-side programming language, it cannot execute code from the client-side. The server must be invoked before the page can change. After all, thats where the code is!

I will move the thread to the JavaScript forum for you.

Regards.
Copy linkTweet thisAlerts:
@vwphillipsJul 19.2004 — Is this the sort of thing
<i>
</i>&lt;html&gt;
&lt;title&gt;&lt;/title&gt;

&lt;head&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;br&gt;
&lt;br&gt;
The copied file may be corrupted with a space between Java and Script
&lt;br&gt;
&lt;br&gt;

&lt;input type=text id="MyTextBox1" value="My Text Box 1" onfocus="javascript:InfoBox(this.id,22,-10,'Information for Text Box One');" onblur="javascipt:HideInfoBox();" onkeydown="javascipt:HideInfoBox();" &gt;
&lt;input type=text id="MyTextBox2" value="My Text Box 2" onfocus="javascript:InfoBox(this.id,-52,30,'Information for Text Box Two');" onblur="javascipt:HideInfoBox();" onkeydown="javascipt:HideInfoBox();" &gt;

&lt;script&gt;

// InfoBox fields
// 0 - automatially contains the text box id
// 1 - the info box Y position from the top of the text box
// 2 - the info box X position from the left of the text box
// 3 - the message to be displayed in the text box
// Customise this line for the Info Box Appearance required.
document.write('&lt;div id=InfoBoxPanel style="position:absolute;visibility:hidden;width:100px;height:50px;font-size:12px;text-align:center;padding:0px;background-color:white;border:solid black 1px;"&gt;&lt;/div&gt;')

InfoBoxId=document.getElementById('InfoBoxPanel');


function InfoBox(id,top,left,message){
ThisId=document.getElementById(id);
ThisTop=top;
ThisLeft=left;
ThisMessage=message;
setTimeout('ShowInfoBox()',100);
}


function ShowInfoBox(){
InfoBoxId.style.top=(FindTop()+ThisTop)+'px';
InfoBoxId.style.left=(FindLeft()+ThisLeft)+'px';
InfoBoxId.innerHTML=ThisMessage;
InfoBoxId.style.visibility='visible';
}

function HideInfoBox(){
InfoBoxId.style.visibility='hidden';
}

function FindLeft(){
if (ThisId.offsetLeft) return ThisId.offsetLeft;
if (ThisId.style.left) return ThisId.style.left;
if (ThisId.style.pixelLeft) return ThisId.style.pixelLeft;
return (null);
}

function FindTop(){
if (ThisId.offsetTop) return ThisId.offsetTop;
if (ThisId.style.top) return ThisId.style.top;
if (ThisId.style.pixelTop) return ThisId.style.pixelTop;
return (null);
}
&lt;/SCRIPT&gt;

&lt;/BODY&gt;
&lt;/HTML&gt;


It should be easy to customise but let me know if you want it changed

It should recognise the text box position but may be confused if in a table.

if you wanted to keep it realy simple you could use title="My message" in the text box
Copy linkTweet thisAlerts:
@guzzerauthorJul 22.2004 — [i]Originally posted by vwphillips [/i]

[B]Is this the sort of thing

<i>
</i>&lt;html&gt;
&lt;title&gt;&lt;/title&gt;

&lt;head&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;br&gt;
&lt;br&gt;
The copied file may be corrupted with a space between Java and Script
&lt;br&gt;
&lt;br&gt;

&lt;input type=text id="MyTextBox1" value="My Text Box 1" onfocus="javascript:InfoBox(this.id,22,-10,'Information for Text Box One');" onblur="javascipt:HideInfoBox();" onkeydown="javascipt:HideInfoBox();" &gt;
&lt;input type=text id="MyTextBox2" value="My Text Box 2" onfocus="javascript:InfoBox(this.id,-52,30,'Information for Text Box Two');" onblur="javascipt:HideInfoBox();" onkeydown="javascipt:HideInfoBox();" &gt;

&lt;script&gt;

// InfoBox fields
// 0 - automatially contains the text box id
// 1 - the info box Y position from the top of the text box
// 2 - the info box X position from the left of the text box
// 3 - the message to be displayed in the text box
// Customise this line for the Info Box Appearance required.
document.write('&lt;div id=InfoBoxPanel style="position:absolute;visibility:hidden;width:100px;height:50px;font-size:12px;text-align:center;padding:0px;background-color:white;border:solid black 1px;"&gt;&lt;/div&gt;')

InfoBoxId=document.getElementById('InfoBoxPanel');


function InfoBox(id,top,left,message){
ThisId=document.getElementById(id);
ThisTop=top;
ThisLeft=left;
ThisMessage=message;
setTimeout('ShowInfoBox()',100);
}


function ShowInfoBox(){
InfoBoxId.style.top=(FindTop()+ThisTop)+'px';
InfoBoxId.style.left=(FindLeft()+ThisLeft)+'px';
InfoBoxId.innerHTML=ThisMessage;
InfoBoxId.style.visibility='visible';
}

function HideInfoBox(){
InfoBoxId.style.visibility='hidden';
}

function FindLeft(){
if (ThisId.offsetLeft) return ThisId.offsetLeft;
if (ThisId.style.left) return ThisId.style.left;
if (ThisId.style.pixelLeft) return ThisId.style.pixelLeft;
return (null);
}

function FindTop(){
if (ThisId.offsetTop) return ThisId.offsetTop;
if (ThisId.style.top) return ThisId.style.top;
if (ThisId.style.pixelTop) return ThisId.style.pixelTop;
return (null);
}
&lt;/SCRIPT&gt;

&lt;/BODY&gt;
&lt;/HTML&gt;


It should be easy to customise but let me know if you want it changed

It should recognise the text box position but may be confused if in a table.

if you wanted to keep it realy simple you could use title="My message" in the text box [/B][/QUOTE]


Hi this is in a table.. ?

Regards

Guzzer
Copy linkTweet thisAlerts:
@guzzerauthorJul 22.2004 — [i]Originally posted by vwphillips [/i]

[B]Is this the sort of thing

<i>
</i>&lt;html&gt;
&lt;title&gt;&lt;/title&gt;

&lt;head&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;br&gt;
&lt;br&gt;
The copied file may be corrupted with a space between Java and Script
&lt;br&gt;
&lt;br&gt;

&lt;input type=text id="MyTextBox1" value="My Text Box 1" onfocus="javascript:InfoBox(this.id,22,-10,'Information for Text Box One');" onblur="javascipt:HideInfoBox();" onkeydown="javascipt:HideInfoBox();" &gt;
&lt;input type=text id="MyTextBox2" value="My Text Box 2" onfocus="javascript:InfoBox(this.id,-52,30,'Information for Text Box Two');" onblur="javascipt:HideInfoBox();" onkeydown="javascipt:HideInfoBox();" &gt;

&lt;script&gt;

// InfoBox fields
// 0 - automatially contains the text box id
// 1 - the info box Y position from the top of the text box
// 2 - the info box X position from the left of the text box
// 3 - the message to be displayed in the text box
// Customise this line for the Info Box Appearance required.
document.write('&lt;div id=InfoBoxPanel style="position:absolute;visibility:hidden;width:100px;height:50px;font-size:12px;text-align:center;padding:0px;background-color:white;border:solid black 1px;"&gt;&lt;/div&gt;')

InfoBoxId=document.getElementById('InfoBoxPanel');


function InfoBox(id,top,left,message){
ThisId=document.getElementById(id);
ThisTop=top;
ThisLeft=left;
ThisMessage=message;
setTimeout('ShowInfoBox()',100);
}


function ShowInfoBox(){
InfoBoxId.style.top=(FindTop()+ThisTop)+'px';
InfoBoxId.style.left=(FindLeft()+ThisLeft)+'px';
InfoBoxId.innerHTML=ThisMessage;
InfoBoxId.style.visibility='visible';
}

function HideInfoBox(){
InfoBoxId.style.visibility='hidden';
}

function FindLeft(){
if (ThisId.offsetLeft) return ThisId.offsetLeft;
if (ThisId.style.left) return ThisId.style.left;
if (ThisId.style.pixelLeft) return ThisId.style.pixelLeft;
return (null);
}

function FindTop(){
if (ThisId.offsetTop) return ThisId.offsetTop;
if (ThisId.style.top) return ThisId.style.top;
if (ThisId.style.pixelTop) return ThisId.style.pixelTop;
return (null);
}
&lt;/SCRIPT&gt;

&lt;/BODY&gt;
&lt;/HTML&gt;


It should be easy to customise but let me know if you want it changed

It should recognise the text box position but may be confused if in a table.

if you wanted to keep it realy simple you could use title="My message" in the text box [/B][/QUOTE]


Hi this is very nearly what i would like, with one small change. Instead of the info message popping up, I was more looking for a text box type field at the bottom of the form which would display the relevant info messages as the user clicked on the various form fields.

Also this will be within another table on my asp page that controls my page layout

Regards

Guzzer
Copy linkTweet thisAlerts:
@vwphillipsJul 22.2004 — <i>
</i>&lt;html&gt;
&lt;title&gt;&lt;/title&gt;

&lt;head&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;center&gt;
&lt;br&gt;
&lt;br&gt;by VicPhillips (22-07-2004)
&lt;br&gt;<a href="www.vicsJavaScripts.org.uk">www.vicsJavaScripts.org.uk</a>
&lt;br&gt;
The copied file may be corrupted with a space between Java and Script
&lt;br&gt;
&lt;br&gt;Much easier, put it where you want.
&lt;br&gt;
&lt;br&gt;Set the required position in the customising variables.
&lt;br&gt;If you want to fix it in a table cell set var InfoBoxFixIt='Yes';
&lt;br&gt;and the cell &amp;lt;td id="InfoBoxFix" valign="top" &gt;
&lt;br&gt;
&lt;br&gt;Concerened what would happen as you scrolled the page so have added a float.
&lt;br&gt;
&lt;br&gt;What is wrong with the status bar anyway??
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;table width="200" border="1"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;input type=text id="MyTextBox1" value="My Text Box 1" onfocus="javascript:InfoBox('Information for Text Box One');" onblur="javascipt:HideInfoBox();" onkeydown="javascipt:HideInfoBox();" &gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;input type=text id="MyTextBox2" value="My Text Box 2" onfocus="javascript:InfoBox('Information for Text Box Two');" onblur="javascipt:HideInfoBox();" onkeydown="javascipt:HideInfoBox();" &gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr height=60&gt;
&lt;td id="InfoBoxFix" valign="top" &gt;&amp;nbsp;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;

&lt;/center&gt;

&lt;script&gt;

// InfoBox fields
// 0 - the message to be displayed in the text box

// Customising Variables
var InfoBoxFixIt='No';
var InfoBoxHeight=50;
var InfoBoxWidth=100;
var InfoBoxTop=450;
var InfoBoxLeft=400;
var InfoBoxFloat='Yes';

// Customise this line for the Info Box Appearance required.
InfoBoxCode='&lt;div id=InfoBoxPanel style="position:absolute;visibility:hidden;width:'+InfoBoxWidth+'px;height:'+InfoBoxHeight+'px;font-size:12px;text-align:center;padding:0px;background-color:white;border:solid black 1px;"&gt;&lt;/div&gt;';


if (InfoBoxFixIt=='Yes'){
document.getElementById('InfoBoxFix').innerHTML=InfoBoxCode
InfoBoxId=document.getElementById('InfoBoxPanel');
InfoBoxId.style.top='0px';
InfoBoxId.style.left='0px';
InfoBoxFloat='No';
}
else {
document.write(InfoBoxCode);
InfoBoxId=document.getElementById('InfoBoxPanel');
InfoBoxId.style.top=InfoBoxTop+'px';
InfoBoxId.style.left=InfoBoxLeft+'px';
}



function InfoBox(message){
ThisMessage=message;
setTimeout('ShowInfoBox()',100);
}


function ShowInfoBox(){
InfoBoxId.innerHTML=ThisMessage;
InfoBoxId.style.visibility='visible';
window.status=ThisMessage;
return true
}

function HideInfoBox(){
InfoBoxId.style.visibility='hidden';
}



var ScrollOld=0;

function Scroll() {
if (window.pageYOffset!= null){
return window.pageYOffset;
}
if (document.body.scrollWidth!= null){
return document.body.scrollTop;
}
return (null);
}

function FloatDo(){
if (ScrollOld!=Scroll()){
InfoBoxId.style.top=(parseInt(InfoBoxId.style.top)+Scroll()-ScrollOld)+'px';
ScrollOld=Scroll();
}
}

onload=ScrollInterval;

function ScrollInterval(){
setInterval('FloatDo()',100);
}


if (InfoBoxFloat=='Yes'){
ScrollInterval();
}

&lt;/SCRIPT&gt;
&lt;br&gt;
&lt;img width=1 height=1000 &gt;
&lt;/BODY&gt;
&lt;/HTML&gt;
Copy linkTweet thisAlerts:
@guzzerauthorJul 23.2004 — Hi Vic thanks for the reply

I have just tried this out but I am unable to get the info box to display in a table cell underneath the rest of the input boxes. I change the line so that i set the var to yes and you have already set the table id for the box, but when run it still puts the messages in the topleft corner of the screen

Any ideas?

Regards

Guzzer
Copy linkTweet thisAlerts:
@vwphillipsJul 23.2004 — sorry about that a last minute tweek mucked it up

<i>
</i>&lt;html&gt;

&lt;head&gt;
&lt;title&gt;&lt;/title&gt;
&lt;meta name="description" content=""&gt;
&lt;meta name="keywords" content=""&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;html&gt;
&lt;title&gt;&lt;/title&gt;

&lt;head&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;center&gt;
&lt;br&gt;
&lt;br&gt;by VicPhillips (22-07-2004)
&lt;br&gt;<a href="www.vicsJavaScripts.org.uk">www.vicsJavaScripts.org.uk</a>
&lt;br&gt;
The copied file may be corrupted with a space between Java and Script
&lt;br&gt;
&lt;br&gt;Much easier, put it where you want.
&lt;br&gt;
&lt;br&gt;Set the required position in the customising variables.
&lt;br&gt;If you want to fix it in a table cell set var InfoBoxFixIt='Yes';
&lt;br&gt;and the cell &amp;lt;td id="InfoBoxFix" valign="top" &gt;
&lt;br&gt;
&lt;br&gt;Concerened what would happen as you scrolled the page so have added a float.
&lt;br&gt;
&lt;br&gt;What is wrong with the status bar anyway??
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;table width="200" border="1"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;input type=text id="MyTextBox1" value="My Text Box 1" onfocus="javascript:InfoBox('Information for Text Box One');" onblur="javascipt:HideInfoBox();" onkeydown="javascipt:HideInfoBox();" &gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;input type=text id="MyTextBox2" value="My Text Box 2" onfocus="javascript:InfoBox('Information for Text Box Two');" onblur="javascipt:HideInfoBox();" onkeydown="javascipt:HideInfoBox();" &gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr height=60&gt;
&lt;td id="InfoBoxFix" valign="top" &gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;

&lt;/center&gt;

&lt;script&gt;

// InfoBox fields
// 0 - the message to be displayed in the text box

// Customising Variables
var InfoBoxFixIt='Yes';
var InfoBoxHeight=50;
var InfoBoxWidth=100;
var InfoBoxTop=450;
var InfoBoxLeft=400;
var InfoBoxFloat='Yes';

// Customise this line for the Info Box Appearance required.
InfoBoxCode='&lt;div id=InfoBoxPanel style=" position:absolute;visibility:hidden;width:'+InfoBoxWidth+'px;height:'+InfoBoxHeight+'px;font-size:12px;text-align:center;padding:0px;background-color:white;border:solid black 1px;"&gt;&lt;/div&gt;';


if (InfoBoxFixIt=='Yes'){
document.getElementById('InfoBoxFix').innerHTML=InfoBoxCode
InfoBoxId=document.getElementById('InfoBoxPanel');
InfoBoxFloat='No';
}
else {
document.write(InfoBoxCode);
InfoBoxId=document.getElementById('InfoBoxPanel');
InfoBoxId.style.top=InfoBoxTop+'px';
InfoBoxId.style.left=InfoBoxLeft+'px';
}



function InfoBox(message){
ThisMessage=message;
setTimeout('ShowInfoBox()',100);
}


function ShowInfoBox(){
InfoBoxId.innerHTML=ThisMessage;
InfoBoxId.style.visibility='visible';
window.status=ThisMessage;
return true
}

function HideInfoBox(){
InfoBoxId.style.visibility='hidden';
}



var ScrollOld=0;

function Scroll() {
if (window.pageYOffset!= null){
return window.pageYOffset;
}
if (document.body.scrollWidth!= null){
return document.body.scrollTop;
}
return (null);
}

function FloatDo(){
if (ScrollOld!=Scroll()){
InfoBoxId.style.top=(parseInt(InfoBoxId.style.top)+Scroll()-ScrollOld)+'px';
ScrollOld=Scroll();
}
}

onload=ScrollInterval;

function ScrollInterval(){
setInterval('FloatDo()',100);
}


if (InfoBoxFloat=='Yes'){
ScrollInterval();
}

&lt;/SCRIPT&gt;
&lt;br&gt;
&lt;img width=1 height=1000 &gt;
&lt;/BODY&gt;
&lt;/HTML&gt;

&lt;/body&gt;

&lt;/html&gt;


PS If you want more than one 'Fixed' location, say and I will mod it
Copy linkTweet thisAlerts:
@guzzerauthorJul 24.2004 — Hi Vic

We [ok YOU] are almost there Thanks!!!!

Only problem that I can see at the moment is when I scroll i get an error with line 118 Invalid Argument?.

Also I can almost do this bit myself but it tends to go wrong at times. is it possible to have the info box displayed with a message like "This is where information relating to field data entries will be displayed" when we first arrive and when none of the other fields have focus?

Kind regards and many many THANSK!

Regards

Guzzer
Copy linkTweet thisAlerts:
@vwphillipsJul 24.2004 — I seem to be making 'A Meal' out of this

I think you had conflicting option

ie you cant have 'fixed' position and 'float'

I should have catered for that though

However I have fixed that so 'float' is only active if 'fix' is 'No'

I have also expanded the code so that you can have any number of 'fixed' or absolute positions on the same page

Save having to fix the currupted code I have uploaded both versions to my web space

Code Old(with fix)

http://homepage.ntlworld.com/vwphillips/TBPU2.htm

Code New

http://homepage.ntlworld.com/vwphillips/TBPU3.htm


I hope you have no further problems but let me know if you do

should have got this right first time round, more hast, less speed

:rolleyes:
×

Success!

Help @guzzer spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...