• 0

A few javascript questions


Question

I'm rather new to javascript and was wondering how a few things were made.

1. How do you place text in a <textarea> when you press a button? (I know u have to do something.value but won't that replace it instead of add text?)

2. How do you place text into a <textarea> when alt + letter are pressed?

3. How do you change the text in a button when it is pressed?

4. If i have a disabled button, how would i enable it only if certain fields were entered? (similarly how would i automatically write text if two fields don't match?)

I'd greatly appreciate it if anybody can answer my questions or give me links to where I can read about how to do these effects.

Thanks

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

1 - <input type=button value="BlaBla" onclick="textareaname.innerText+='texttowrite';">

2 - <body ... onkeypress="checkAlt()" ...>

function checkAlt()

{

if (event.altKey && event.keyCode=="letterasciicode")

dosomething;

}

3 -

<input type=button ... onClick="changeValue(this);" ...>

function changeValue(but)

{

but.value="somevalue";

}

enough for now... gonna code some more

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.