SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Canada
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    setValue help, newbie

    I have a script that displays a div tag with a character in it, when the user clicks on the character, it changes into another character. I need to use this as input for a PHP script, how can I make the character being displayed POST so that I can use it with my PHP script?
    Code:
    <script type="text/javascript"><!--
    
    var inputs;
    var clickers=new Array();
    var options=new Array("o","x","O","X","g","d","-");
    
    function parsePage(){
    
      inputs = document.getElementsByTagName("input");
    
      for( var n=0; n<inputs.length; n++){
        if(inputs[n].type=="hidden" && inputs[n].getAttribute("special")){
    
          clickers[clickers.length]			= document.createElement("div");
          clickers[clickers.length-1].className	= "clicker";
          clickers[clickers.length-1].id		= inputs[n].name;
          clickers[clickers.length-1].appendChild( document.createTextNode("-") );
    
          clickers[clickers.length-1].onclick	= function(){
            nextChar(this);
          }
    
          inputs[n].parentNode.insertBefore( clickers[clickers.length-1], inputs[n]);
    
        }
      }
    
    }
    
    function nextChar(el){
    
      while( el.childNodes.length>0 ){
        el.removeChild( el.firstChild );
      }
    
      for( var n=0; n<options.length; n++ ){
        if( document.getElementsByName(el.id)[0].value == options[n] ){ break; }
      }
    
      n=(n>options.length-2)?0:n+1;
    
      document.getElementsByName(el.id)[0].value = options[n];
      el.appendChild( document.createTextNode( options[n] ) );
    
    }
    
    //--></script>
    Here's the code in action: http://www.mc-steve.com/tab2
    I don't know much javascript, but I assume this should be pretty simple,
    Thank you for the help.

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <input type="hidden" name="char">
    or use
    Code:
    <input type="text" name="char" style="border:1px solid white;width:15px;color:#333333;" disabled="true">
    then u can post it!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •