Onclick send "id" to textbox


function logMsg(msg){
    if ( window.console && window.console.log )
      console.log(msg);
    else
      alert(msg);
  }

  try{
     // if so, let's reset it's class and remove from the cache
     
     this.className="default";
     delete selectedLinks[thisID];
     logMsg("removing: " +thisID);
     } else {
     
     // if not, go ahead and set the class to 'highlight' add to cache
     this.className= "highlight";
     selectedLinks[thisID] = this;
     logMsg("adding: " +thisID);
      }
         
     // prevent default action, do not follow the link
     return false;
      };
      })(i);
    }
  } catch(exception){ logMsg(exception.toString()); }
 </script>

The above JS code alerts when the following link “id’s” clicked


<li class="seat_01 A"><a href="#row_01" id="01A">01A</a></li>
<li class="seat_01 B"><a href="#row_01" id="01B">01B</a></li>

What i want is, NOT THE ALERT…bt somehow to send the “id” name to the textbox like “01A” when they are clicked:


<input type="text" name="seatid">

Replace this line

alert(msg);

with this

document.getElementById("seatid").value = msg;

thanks for the reply : )

bt i wish it worked by ur method…bt ive tried dat too
i guess, u really have to change these lines aswell:


 this.className= "highlight";
          selectedLinks[thisID] = this;
          logMsg("adding: " +thisID);

any suggestions how ?

That’s impossible to say unless you show how the code in your first post is actually called. The meaning of the ‘this’ keyword differs a lot depending on how the code is called. We also need to be told how the thisID variable is assigned.

this is the link to my site

popcornmovies.net/movie_showtimes.php?showtime=6:30PM

the screen has seats.
upon clicking a desired seat that has a link:


<ul id="seatplan">
      <li class="seat_01 A"><a href="#row_01" id="01A">01A</a></li>
      <li class="seat_01 B"><a href="#row_01" id="01B">01B</a></li>
      <li class="seat_01 C"><a href="#row_01" id="01C">01C</a></li>

      ...and continous for the rest.

the javascript code (posted earlier) enables, the highlighting of seats and selection/deselection of them. As well as the alert msg.

then again, their is a textbox after “YOU HAVE SELECTED:” (its just blk bkgnd), i want to send the “id” displayed in the alert box to the textbox…

THANKS AGAIN FOR THE REPLY,

It works for me. :confused:

The fact that your IDs are invalid might be a problem (IDs cannot start with a digit).
You also define a local variable with the same name as a formal function argument, which isn’t allowed:

return function(e){
    ...
    for (var e in selectedLinks)