Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > Web Development
You last visited: Today at 22:10

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



JS - set value if select an option

Discussion on JS - set value if select an option within the Web Development forum part of the Coders Den category.

Reply
 
Old   #1



 
Looneytune's Avatar
 
elite*gold: 70
The Black Market: 376/0/0
Join Date: Mar 2007
Posts: 24,344
Received Thanks: 12,389
Post JS - set value if select an option

Hallo,

ich wuerde gern eine Art "vorgefertigte" Antwort mittels Javascript in ein Form Input setzen, indem ich per Form Select eine Option auswaehle, hat zufaellig jemand ein Sample?

Zum Verstaendnis:
PHP Code:
<form method="post">

<
select name="top5" size="3">
      <
option>1</option>
      <
option>2</option>
      <
option>3</option>
      <
option>4</option>
      <
option>5</option>
    </
select>

<
textarea name="message"></textarea>
<
input type="submit" value="send" name="send" />

</
form
Option 1 sollte dann bei der Textarea "Hallo, mein Name ist Kevin." als Wert setzen. Option 2 usw. aber was anderes Vorgefertigtes.

Gruß und Danke
Looneytune is offline  
Old 09/29/2012, 19:29   #2
 
PseudoPsycho's Avatar
 
elite*gold: 1715
Join Date: Dec 2011
Posts: 672
Received Thanks: 207
Den HTML-Teil übernommen und modifiziert:
HTML Code:
<form method="post" onSubmit="setAnswer(); return false;">

<select name="top5" id="top5sel" size="3">
      <option value="0">Hallo</option>
      <option value="1">blabla</option>
      <option value="2">blubblub</option>
      <option value="3">irgendwas</option>
      <option value="4">Lorem Ipsum</option>
</select>

<textarea name="message" id="top5message"></textarea>
<input type="submit" value="send" name="send" />

</form>
Und im Head-Teil:
HTML Code:
<script type="application/javascript">
	function setAnswer(){
		var answers=Array();
		answers[0]='Hallo, mein Name ist Kevin.';
		answers[1]='...';
		answers[2]='...';
		answers[3]='..anderes';
		answers[4]='dolor si amet.';
		
		document.getElementById('top5message').value=answers[document.getElementById('top5sel').value];
	}
</script>
PseudoPsycho is offline  
Thanks
1 User
Reply


Similar Threads Similar Threads
Set option and lines !!!!
08/07/2012 - Dekaron Private Server - 12 Replies
Guyz how can i change my set options to my own numbers for example: Helmet got 4 lines HP how can i change these hp lines to defense linesfor example 4lines contains 200 increase defense instead of HP lines :D thnx alot sorry for my bad explaination
Metin 2 Select Character select error
02/26/2011 - Metin2 Private Server - 1 Replies
Dabei-ist das spiel Charakter-Auswahl Error help Log Files 0225 23:37:16227 :: CEffectManager::RegisterEffect - LoadScript(d:/ymir work/effect/hit/percent_damage1.mse) Error 0225 23:37:16227 :: CInstanceBase::RegisterEffect(eEftType=264, c_szEftAttachBone=, c_szEftName=d:/ymir work/effect/hit/percent_damage1.mse, isCache=1) - Error 0225 23:37:16227 :: CEffectManager::RegisterEffect - LoadScript(d:/ymir work/effect/hit/percent_damage2.mse) Error 0225 23:37:16227 ::...
Option Codes
10/23/2010 - Dekaron Private Server - 6 Replies
In status.csv there are option codes example: "DAMAGE_ADD" stuff like this. Is there a spot in the files that has all of these written down? Like a file showing what all you can choose from?
Option !
04/18/2007 - Silkroad Online - 1 Replies
i need To Know something About Bot option .. When It going To Atk The monster Its Stopping near it and dont atk it .. or may atk it after like 20-30 sec .. From wht tht Happning ? need help in tht plz ASAP :cry:



All times are GMT +2. The time now is 22:10.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.