hi..
in my project online bus ticket booking there is a jsp page of bus structure in which there are three images used.
one is for selected seat,2nd is for booked seat,and the 3rd one is for available seat.

when i click on available seat it will convert in to selected seat image and seat number is displaying in the text box.
And now the issue is i want to remove the seat number from text box when i click on the same seat image 2nd time.
Anyone cal tell me the solution.
For the above functionality i m using javascript and jsp page

It is difficult to try to help you without seeing any code or image of the page. Anyway, I will try. The way to remove the seat number from text box should be similar to how you add the seat number to the text box. The only different is that you now are not appending the seat number to the text box but rather compare the value of the text box with the seat number you got. Then, remove it from the text box value.

For example

function appendText(txtBoxID, seatNum) {
  var el = document.getElementById(txtBoxID)
  // append seat number to the end with a new line if 'el' exists
  if (el) { el.value = el.value + "\n"+seatNum }
}

function removeText(txtBoxID, seatNum) {
  var el = document.getElementById(txtBoxID)
  // remove the seat number which may have a leading new line if 'el' exists
  if (el) {
    var regEx = new RegExp("\\n?"+seatNum, "i")  // case-insensitive
    if (el.value.match(regEx)) {  // found the seat number
      el.value = el.value.replace(regEx, "")  // remove the found text
    }
  }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.