| Author |
add an element to select box
|
Pradeep Adibatla
Ranch Hand
Joined: Oct 27, 2009
Posts: 336
|
|
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
Joined: Sep 01, 2006
Posts: 196
|
|
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
Joined: Oct 27, 2009
Posts: 336
|
|
|
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
Joined: Sep 01, 2006
Posts: 196
|
|
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
Joined: Oct 27, 2009
Posts: 336
|
|
|
How does one transfer control to another jsp?? It would be great If I can have one example...
|
 |
ravindra patil
Ranch Hand
Joined: Sep 01, 2006
Posts: 196
|
|
var url = "sample.jsp?<%=paramBuff.toString()%>";
document.location.href=url;
|
 |
Pradeep Adibatla
Ranch Hand
Joined: Oct 27, 2009
Posts: 336
|
|
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
Joined: Jan 10, 2002
Posts: 56178
|
|
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.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
ravindra patil
Ranch Hand
Joined: Sep 01, 2006
Posts: 196
|
|
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
Joined: Jan 10, 2002
Posts: 56178
|
|
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
Joined: Oct 27, 2009
Posts: 336
|
|
|
Bear,could you tell how it should be done using JS...
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56178
|
|
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.
|
 |
 |
|
|
subject: add an element to select box
|
|
|