HighDots Forums  

Pop-Up Pass Multiple Dynamic Values Between Forms

Javascript JavaScript language (comp.lang.javascript)


Discuss Pop-Up Pass Multiple Dynamic Values Between Forms in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
cwwilly
 
Posts: n/a

Default Pop-Up Pass Multiple Dynamic Values Between Forms - 04-19-2004 , 07:06 PM






Hello,

Thanks for taking a look at this!

Problem:
I'm trying to pass multiple dynamic values between a slaveform and a
masterform. The problem I'm having is on the slaveform I loop through
multiple records and want two values depending on the row they select.

slaveform: x=selected
Radio ID Location
x 1 1
2 2
3 3
..
..
..

So in the slaveform I want the ID=1 and Location=1 passed back to the
masterform. Since the row has been selected by selecting the radio
button. I'm using ASP to loop through the records of the database if
this makes any difference.

I would really appreciate an example or suggestions if you guys have
any.

Thanks !

Reply With Quote
  #2  
Old   
Vincent van Beveren
 
Posts: n/a

Default Re: Pop-Up Pass Multiple Dynamic Values Between Forms - 04-20-2004 , 03:16 AM






Hey,

To return the information you can alway use opener. opener refers to the
parent document that opened the window. Something like:

if (opener && !opener.closed && opener.returnedValues) {
opener.returnedValues(id, location);
}

returnedValues is a function you have to write in the master form.

Now there are several ways to solve the other problem. You could build
an additional array, or you could make multiple hidden fields, but I
would think the following would be the easiest. You could integrate the
values in the radiobutton. For example, you could do the following:

<INPUT TYPE="radio" NAME="list" VALUE="1,0"> ID 1, Location 0
<INPUT TYPE="radio" NAME="list" VALUE="2,1"> ID 2, Location 1
<INPUT TYPE="radio" NAME="list" VALUE="3,2"> ID 3, Location 2

Now once you press 'the' button you can do the following

function sendBackValues()
{
list = document.myform.list;
for (i=0;list.length;i++)
{
if (list[i].checked) {
if (opener && !opener.closed && opener.returnedValues)
{
values = list[i].value.split(',');
opener.returnedValues(values[0], values[1]);
return;
}
}
}
alert('No options checked!');
}

Good luck,
Vincent


cwwilly wrote:
Quote:
Hello,

Thanks for taking a look at this!

Problem:
I'm trying to pass multiple dynamic values between a slaveform and a
masterform. The problem I'm having is on the slaveform I loop through
multiple records and want two values depending on the row they select.

slaveform: x=selected
Radio ID Location
x 1 1
2 2
3 3
.
.
.

So in the slaveform I want the ID=1 and Location=1 passed back to the
masterform. Since the row has been selected by selecting the radio
button. I'm using ASP to loop through the records of the database if
this makes any difference.

I would really appreciate an example or suggestions if you guys have
any.

Thanks !


Reply With Quote
  #3  
Old   
Chad S
 
Posts: n/a

Default Re: Pop-Up Pass Multiple Dynamic Values Between Forms - 04-20-2004 , 12:27 PM



Hey Vincent,

Thanks so much for helping me out with this. I have the general idea
now of what you're suggesting. I am unclear how I should write the
returnedValues function on the parent document.

Could you give me just a little more direction ? Thanks !

Chad

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Reply With Quote
  #4  
Old   
Vincent van Beveren
 
Posts: n/a

Default Re: Pop-Up Pass Multiple Dynamic Values Between Forms - 04-21-2004 , 03:14 AM



Sure


Quote:
Could you give me just a little more direction ? Thanks !

returnedValue is a function you can write yourself. I just thought it
was a good name, but you can name it 'monkey' if you like. You could
process the values in the following manner. Depending on what you want,
you could do anything else with it. This would be a possible implementation


<script language="JavaSCript">
<!--
function returnedValue(id, location) {

f = document.myForm;
f.id.value = id;
f.location.value = location;
}
<!-- -->
[...]
<FORM NAME="myForm" [...]>
[...]
<INPUT TYPE="hidden" name="id">
Location: <INPUT TYPE="text" name="location">
[...]
</FORM>

I hope it helps,
Vincent



Reply With Quote
  #5  
Old   
Vincent van Beveren
 
Posts: n/a

Default Re: Pop-Up Pass Multiple Dynamic Values Between Forms - 04-21-2004 , 03:17 AM



Oh, I forgot, naming a name="id" might go wrong, since ID is usually
already an existent properties of an object. You might better call it
'theId' or something. And I made a typo in the method name. There should
be an s at the end of function returnedValues(id, location);

Vincent van Beveren wrote:

Quote:
Sure


Could you give me just a little more direction ? Thanks !


returnedValue is a function you can write yourself. I just thought it
was a good name, but you can name it 'monkey' if you like. You could
process the values in the following manner. Depending on what you want,
you could do anything else with it. This would be a possible implementation


script language="JavaSCript"
!--
function returnedValue(id, location) {

f = document.myForm;
f.id.value = id;
f.location.value = location;
}
!-- --
[...]
FORM NAME="myForm" [...]
[...]
INPUT TYPE="hidden" name="id"
Location: <INPUT TYPE="text" name="location"
[...]
/FORM

I hope it helps,
Vincent



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.