comments

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
micknic
Forum Commoner
Posts: 37
Joined: Thu Feb 27, 2003 1:27 pm
Location: belgium

comments

Post by micknic »

Hi guys

I'm doing a intranet. I would like that when user clic on a textbox a dialbox or message box appear to give instructions to the user. A bit like comments in Word

Could someone give me advices???
User avatar
daven
Forum Contributor
Posts: 332
Joined: Tue Dec 17, 2002 1:29 pm
Location: Gaithersburg, MD
Contact:

Post by daven »

Two ways to do this:

1. use alt messages.
2. make a javascript alert function

Code: Select all

<script language="javascript">
function tooltip(itemName)&#123;
switch(itemName)&#123;
  case 'textbox1':var text="This is a tool tip";break;
  case 'textbox2':var text="This is a another tip";break;
&#125;
alert(text);
</script>
<HTML>
<input type=text name="textbox1" onclick="tooltip(this.name)">
<input type=text name="textbox2" onclick="tooltip(this.name)">
<input type=text name="textbox1" alt="Hello">
</HTML>
micknic
Forum Commoner
Posts: 37
Joined: Thu Feb 27, 2003 1:27 pm
Location: belgium

Post by micknic »

Hi daven

I tried your solution. This is my code:

<script language="javascript">
function tooltip(itemName){
switch(itemName){
case 'prenrech':var text="This is a tool tip";break;
case 'textbox2':var text="This is a another tip";break;
}
alert(text);
</script>
<html>
<body>
<form action="findfin.php" method="post">
<H3>Cette page vous permet de trouver l'adresse e-mail d'un membre de la communauté</H3>
<p>
<p>
<p>
<p>
<p>
Introduisez le prénom de la personne recherchée:<input type="text" name="prenrech" size="30" maxlength="30" onclick="tooltip(prenrech)">
<p>
<p>
<p>
<p>
<p>
<p>
<p>
Introduisez maintenant son nom:<input type="text" name="nomrech" size="20" maxlength="20">
<p>
<p>
<p>
<p>
<p>
<p>
<p>
<input type="submit" value="Effectuer la recherche">
</form>
</body>
</html>

When I click on the first textbox i got message: this page contains errors....

What's the problem???
Hope you can help me

:P :lol:
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Code: Select all

<html><!-- html is the outmost tag (ignoring instructions) -->
	<head>
		<script type="text/javascript">
			function showHelp(itemName)&#123;
				switch(itemName)&#123;
					case 'prenrech':var text="This is a message box";break;
					case 'textbox2':var text="This is a message box";break;
				&#125;
				alert(text);
			&#125; <!-- forgot a closing bracket, that's why indents are so usefull ;) -->
		</script>
		<style type="text/css">
			form p &#123; padding-bottom: 40px; &#125;
		</style>
	</head>
	<body>
		<form action="findfin.php" method="post">
			<H3>Cette page vous permet de trouver l'adresse e-mail d'un membre de la communauté</H3>
			<p>
				Introduisez le prénom de la personne recherchée:
				<input type="text" name="prenrech" size="30" maxlength="30" />
				<input type="button" value="aide" onClick="showHelp('prenrech');" />
			</p>
			<p>
				Introduisez maintenant son nom:<input type="text" name="nomrech" size="20" maxlength="20">
			</p>
			<p>
				<input type="submit" value="Effectuer la recherche">
			</p>
		</form>
	</body>
</html>
hope that helps ;)
micknic
Forum Commoner
Posts: 37
Joined: Thu Feb 27, 2003 1:27 pm
Location: belgium

Post by micknic »

it works

Thank you very much
Post Reply