• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

add an element to select box

 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a jsp which has a select box and a button...

On click of that button I pop up a window(with a text field,OK,cancel buttons) which allows a user to enter a value in the text filed it contains !!!

Now on OK,the window should dissapear(not done) and the value should be set to the existing select box which already has values!!!


 
ravindra patil
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
write mehtod onclick of Ok button

use DHTML to set the value

var obj --refers your jsp
like top.opener.Document
var objName = obj.getElementById(ID attribute of your selecttag);

var opt = obj.createElement("option");
opt.appendChild(obj.createTextNode("<%=sValue%>"));
opt.value="<%=sValue%>";
objName.appendChild(opt);
 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actualy that select is in a jsp...and this window I wrote in html.So on button click in jsp,I am popping the window saved as a html file .Now in this html file on OK button click I should write a JS .But how to get select tag attribute present in jsp in this JS function saved as .html?select tag and the JS function are in 2 different places!! I am confused here.
 
ravindra patil
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think you need to transer control to another jsp on onclick event of Ok button which will be hidden and do the processing in that jsp

just try
 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How does one transfer control to another jsp?? It would be great If I can have one example...
 
ravindra patil
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
var url = "sample.jsp?<%=paramBuff.toString()%>";

document.location.href=url;
 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am still new to Javascript hence the strutggles.

?<%=paramBuff.toString()%>";


could you just explain this?what should come here and what the one you have written does?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64717
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pradeep Adibatla wrote:I am still new to Javascript hence the strutggles.

?<%=paramBuff.toString()%>";


could you just explain this?what should come here and what the one you have written does?

That is JSP (and bad JSP at that) and has nothing to do with JavaScript.
 
ravindra patil
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
its scriplets defined in java , i am appending it to that jsp so i can get that parameters in that jsp using request.getParameter();

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64717
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ravindra patil wrote: its scriplets defined in java , i am appending it to that jsp so i can get that parameters in that jsp using request.getParameter();

This is an HTML forum -- please refrain from posting JSP code. There is no need to use JSP to solve this issue.
 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear,could you tell how it should be done using JS...
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64717
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry but I am still unsure what you are trying to accomplish. Adding an option to a select is fairly easy using the select element's add() method, but in your description you start talking about other windows and links and such without explanation which just confuses the whole issue.

Perhaps you can state, clearly and succinctly, what it is you are trying to do.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic