#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    3
    Rep Power
    0

    Question Generate personal button with java (textual adventure building)


    Thread moved =>

    Hi all,

    I've got two questions :

    I use this script, send "word" for receive "answer" :

    Code:
    <form name="form1" method="post">
      <textarea name="fname1" value=""></textarea><br>
    <input type="submit" value="send"></form> 
     
    <script type="text/javascript">
    	function validateForm() {
    	var x = document.forms["form1"]["fname1"].value;
    	if (x === "word" ) {
    		document.forms["form1"].innerHTML +=("answer");   
    	} return false; }
    		document.forms["form1"].onsubmit = validateForm;
    </script>
    -> But i'd like receive this button (with his script) instead of "answer" :

    Code:
    <div id="1">
    <input type="button" onClick="return toggleMe('2')" value="to 2"></div>
    <div id="2" style="display: none;">
    2
    <input type="button" onClick="return toggleMe('3')" value="to 3"></div>					  
    <div id="3" style="display: none;">
    3
    <input type="button" onClick="return toggleMe('4')" value="to 4"></div>  
    <div id="4" style="display: none;">
    4 etc
    </div>
    Code:
    //in <head>
    
    <script type="text/javascript">
    function toggleMe(a){
      var next=document.getElementById(a);
      var b=new String();
      b= a-1;
      var prev=document.getElementById(b);
      if(!next)return true;
      if(next.style.display=="none"){
        next.style.display="block"
        prev.style.display="none"
        window.scrollTo(0,0);
      } else {
        next.style.display="none"
      }
      return true;
      }
    </script>
    -> Second question, is it also possible to define the button that will appear depending on what you will write in the text area ?

    Thanks for your help.
  2. #2
  3. Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    May 2004
    Location
    Superior, CO, USA
    Posts
    2,418
    Rep Power
    1713
    I answered this in your crosspost.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    3
    Rep Power
    0
    I move this thread, it's javascript, not java.
  6. #4

  7. Join Date
    Jul 2013
    Location
    Melbourne
    Posts
    36
    Rep Power
    0
    thanks for that
    Finelarme

IMN logo majestic logo threadwatch logo seochat tools logo