how to pass radiobutton value from one jsp to another jsp - javascript

i have a jsp page on which i have a image, on click of that image i am opening a modal winwdow having radio buttons with corresponding value(another jsp)...
what i am trying to achieve is on selection of a radio button,assign it's value to a textbox which is on parent page...
Let me tell you that i am not submitting any form ...i just want to close this window and assign it's value to textbox on parent jsp, on selection of radio button
i tried to do it with session but couldn't figure out exact way...
any suggestions or inputs will be highly appriciated.
Thanks

Assume that in the parent window this is the text box that needs to be updated.
<input type="text" id="txtBoxDisplay" value=""/>
In parent window create a function to update the textbod with the new text
<script>
....
....
....
function updateTextBox(theTextString)
{
$("#txtBoxDisplay").val(theTextString); //assuming you are using jquery
document.getElementById('txtBoxDisplay').value = theTextString; // if not using jquery
}
</script>
In the child page/modal window use the following code to access the parent jsp function
window.opener.updateTextBox("Display this text in the parent text box");
You can also use
parent.updateTextBox("Display this text in the parent text box");
For more details see the following links
http://chiragrdarji.wordpress.com/2007/03/10/call-parent-windows-javascript-function-from-child-window-or-passing-data-from-child-window-to-parent-window-in-javascript/
http://www.rgagnon.com/jsdetails/js-0066.html

If you're not submitting any form, then the server obviously doesn't know anything about the selection you made in the modal window.
Use JavaScript to initialize the text field in the parent window with the selected radio. Since I gues you're using JQuery to open the dialog, then you shouldn't have any problem calling a JavaScript function defined in the parent window from the modal dialog.

Related

Updating the value of a Brazos Input Text control client side

We have a CSHS with a Data Table and Global Filter exposed. After entering a value in the filter and limiting the table, they want to be able to click a button that opens a modal and have it available in an input text in the modal and, by doing so, have it bound to a local variable in the CSHS so it can be used in scripts.
I am able to get the value to show up in the modal (code a bit kludgy but it works) but the input text on the modal doesn’t seem to think it has changed and isn’t binding the value to the variable bound to the input text. Suggestions?
Here’s the code I’m using to get the Global Filter text to display on the modal input text: (added a class name of “searchValue” to the input text in the modal – only one data table on the CSHS so I can use the [0] index of getElementsByClassName)
var el = document.getElementsByClassName('searchValue')[0];
el.getElementsByTagName('Input')[0].value = document.getElementsByClassName("dataTables_filter")[0].firstChild.firstChild.nextSibling.value;
Try calling the jQuery .change() on the input text field after changing the value.
For example:
$("#input_div_1_1_1").val("test").change()

How to get value from one modal window textbox and put it to another textbox in another modal window?

I would like to ask you guys for a little help. I wanted to have my textbox in a modal to have the same value in another textbox in another modal window. The problem is I don't know how. I'm new in using modal windows. Hoping that someone can help me.
Illustration:
Modal window1 Modal Window 2
textbox1 textbox2
*textbox1.value must be equal to textbox2.value upon typing. so when the modal window 2 comes out it must have already a value which is the value of Modal window1 textbox1.
Well you can do this:
$('#textbox1').keydown(function(){
$('#textbox2').val($(this).val());
});
I presume that you have two textboxes with id textbox1 and textbox2.
I've attached keydown handler, which copies the textbox1's value and assigns it to textbox2 as you type.

How to grab the contents of a div and insert it into a hidden input

I built a simple CMS in Laravel 4. I've decided to switch from my old editor to this markdown editor.
My old editor used a textbox and so all I had to do was submit the form and it was passed from the view to the controller and inserted into the database etc.
However, this new editor works by turning the markdown into html and that html is inserted within a div that looks like this:
<div id="preview" class="wmd-preview"></div>
I still want to use my old form to submit the contents of the div, so my question is this:
Is there a way to insert the contents of my "preview" div into some sort of hidden input in my form?
Alternatively, is there a better way to submit the contents of my post?
get the content of your div by its id
var a = document.getElementById('preview').innerHTML;
document.getElementById('hid').value = a //create a hidden input give it an id hid
To answer your question about firing the function every time a key is pressed, I would use a jQuery event listener like .keyup().
http://api.jquery.com/keyup/

how to assign asp.net label using JavaScript and Ajax

I am trying to assign a asp.net label using JavaScript and then whenever label text get changed to trigger Ajax UpdatePanal and update a grid based on text in the label.
This is what I have currently tried:
`function ChangeTeam(sPARENT_ID, sPARENT_NAME) {
alert("me1");
document.getElementById("Label4").value = "Text 123";
document.forms[0].submit();
}
function PopupHelp(page) {
var url = page;
window.open(url,'Select','width=600,height=600,status=0,resizable=1,scrollbars=1,toolbar=0,location=1');
}'
So what this is actually doing is: User click on a button under PAGE1 a new windows opens with PAGE2, PAGE2 contains checkboxes for user to select, once the user has made the selection on PAGE2 the selection ID is passed via JavaScript back to PAGE1 CHANAGETEAM() function where that function should populate a hidden label "Label4" and then based on that population of the label Ajax Panel should trigger and update a grid with the ID selected.
With the code I have above it gets back into CHANGETEAM() function and sends that alert ME1 but looks like nothing past that works. What am I doing wrong?
Thanks for your help.
The way .NET's controls are named on the page vs their IDs how they're rendered are different. If you inspect the source code of the rendered page, it's probably something along the lines of UpdatePanel1_Label4 instead of just Label4.
Besides hardcoding that name in, you can also get the rendered Id with the ClientId Property. So your code can look like
document.getElementById('<%= Label4.ClientID %>').value = "Text 123";

Passing input value from parent window to popup window

I had made a parent window that includes a text box and hyperlink to open a PopUp Child JSP Page.
I wish to access the value entered in textbox on the Child JSP through request.getParameter method. How can I achieve this?
Just pass the value along as querystring in the URL of the popup window.
Assuming that you've a
<input type="text" id="foo">
you can pass it to the popup window as follows
var foo = document.getElementById('foo').value;
window.open('child.jsp?foo=' + encodeURIComponent(foo));
then you can access it in popup window as follows
<p>The value is ${param.foo}</p>

Categories