Probably a stupid HTML question

PAz

PAz

Soldato
Joined
18 Oct 2002
Posts
6,564
Location
Bucks
I'm sure I've done this before using either HTML or Javascript...

What I need to do is click a button, and then the action puts some text into a textbox.

Any helpers? I know I'll kick myself when I see the solution!

Thanks
 
Code:
<html>

<head>

<title>JavaScript Alerts!</title>

</head>

<body>

<script language="javaScript" type="text/javascript">

</script>

<div align="center">

<form acriotn="" method="POST">

<input type="button" name="alertbutton" value="Click Me!" onClick="alert('Change this text whilst preserving the quotation marks to what you wish to appear in the messagebox...')"></input>

</form>

</div>

</body>

</html>

:)
 
Triad2000 said:
As far as I can see it shows him how to construct an html button. Was that not what he was after?

He's after a javascript alert isn't he? Or have I got the wrong end of the stick yet again? :o Extremley sorry if I have... :(
 
Trigger said:
Code:
<html>

<head>

<title>JavaScript Alerts!</title>

</head>

<body>

<script language="javaScript" type="text/javascript">

</script>

<div align="center">

<form acriotn="" method="POST">

<input type="button" name="alertbutton" value="Click Me!" onClick="alert('Change this text whilst preserving the quotation marks to what you wish to appear in the messagebox...')"></input>

</form>

</div>

</body>

</html>

:)

Thanks, thats kind of it. Need it to appear in an actual HTML textbox/field though as opposed to a window prompt.

I tried changing the alert to the textbox name but that didn't work!
 
Triad2000 said:
"I'm sure I've done this before using either HTML or Javascript..." or have I had too many beers?


hahaha, I'm off the drink at the moment so I cant even use that excuse :o

ta again for all the help
 
PAz said:
Thanks, thats kind of it. Need it to appear in an actual HTML textbox/field though as opposed to a window prompt.

I tried changing the alert to the textbox name but that didn't work!

I think I see what you mean. Off the top of my head, I can remember how to put text into the page but not write to HTML elements- will look it up for you though :)

If it's any use, change

Code:
alert

to

Code:
document.write

:cool:
 
Et Voila! :D After a bit of playing about, I've done what you're after:

Code:
<html>

<head>

<title>JavaScript Alerts!</title>

</head>

<body>

<script language="javaScript" type="text/javascript">

</script>

<div align="center">

<form action="" method="POST" name="form1">

<input type="button" name="alertbutton" value="Click Me!" onClick="document.form1.output.value='Change this text whilst preserving the quotation marks to what you wish to appear in the text box...'"></input>

<p>

<textarea name="output">

</textarea>

</p>

</form>

</div>

</body>

</head>

:)
 
Cuchulain said:
Why have you opened a javascript tag and closed it with no actual javascript in between?

Oops, I forgot to take it out :o It ws for another method I was trying and for some reason, I put the <form> tags inside the javascript tags and then moved it without deleting them :o Sorry :(
 
Dude, i asked practically the same question and no-one answered me, so ill tag on your thread - can you use a drop down box to select an <option> which then affects what appears in the said text box...?
 
Trigger said:
Oops, I forgot to take it out :o It ws for another method I was trying and for some reason, I put the <form> tags inside the javascript tags and then moved it without deleting them :o Sorry :(

Sorry, looked like I was criticising, that wasn't the intention, I just wondered if there was a reason for it.
 
jonnyg said:
Dude, i asked practically the same question and no-one answered me, so ill tag on your thread - can you use a drop down box to select an <option> which then affects what appears in the said text box...?

Here you go:

Code:
<form name="form1">

<select name="Colour">
  <option selected>--Select Colour</option>
  <option value="Red" onClick="document.form1.output.value='Red'">Red</option>
  <option value="Green" onClick="document.form1.output.value='Green'">Green</option>
  <option value="Blue" onClick="document.form1.output.value='Blue'">Blue</option>
</select>
<br>
<textarea name="output">

</textarea>

</form>
 
Oooo, thank you :)

I would code my own, really i would... but im lazy... :)

Only thing is, is i want something to be cross referenced and then displayed in the box.... i.e:

Selecting 'Red' from the drop down box, will then display 'Roses' (for example) in the text box below. But, then selecting 'Blue' will show 'Sea' in the text box... The code you gave me there doesnt do that. Plus, i fear i may need a database to cross reference...
 
Last edited:
Back
Top Bottom