Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing values to opener with duplicate fieldnames

Status
Not open for further replies.

DoTheLoop

Programmer
Sep 12, 2003
14
0
0
SE
I know this is stupid to even be trying, but it is as it is and I cannot change this fact. The fact that it is a dynamic HTML-generator (engine) that creates a page with several duplicate fieldnames, on this page (parent) there are links that opens a childwindow where the user can change fieldvalues by typing a new value in childwindow - press a link and see the change without submit. This is easy as long as the parent window has unique fieldnames otherwise thers an error or nothing happens.

Well this is my problem now - The parentwindow has several fields (input type=text and input type=hidden) that has same names.

Example:
<html>
<head><title></title>
<body>
<form>
Name:<input type=text name=my_name value=&quot;John Doe&quot;>
<input type=hidden name=my_name_id value=3>
Adress:<input type=text name=my_adress value=&quot;Street&quot;>
Phone<input type=text name=&quot;my_phone&quot; value=&quot;123456&quot;><a href=&quot;#&quot; onClick=javascript:window.open('popfromtheParent.html','pop','toolbar=no,width=600,height=550,resizable=yes,top=75,left=150');>Change</a>
<br>-----------------------------------------------
Name:<input type=text name=my_name value=&quot;Graham Wills&quot;>
Adress:<input type=text name=my_adress value=&quot;654321&quot;>
Phone<input type=text name=&quot;my_phone&quot; value=&quot;Backyard&quot;><a href=&quot;#&quot; onClick=javascript:window.open('popfromtheParent.html','pop','toolbar=no,width=600,height=550,resizable=yes,top=75,left=150');>Change</a>
</form>
</body>
</html>
This is a dynamic page and the amount of fields arent known until page is loaded. The type sofar is only &quot;text&quot; and &quot;hidden&quot;.

I have made an effort in trying to keep track of changes in respective fields on parent window with arrays, like:

<script language=&quot;JavaScript&quot;>
function parseElements() {
var myArray = new Array(this.document.forms[0].elements.length);
[0].elements.length);
for (i=0; i<this.document.forms[0].elements.length; i++) {
[0].elements.value);
if ((this.document.forms[0].elements.type == &quot;text&quot;) || (this.document.forms[0].elements.type == &quot;hidden&quot;)) {
globalArray = this.document.forms[0].elements.value;
}
}
}
</script>

Thus making an array with starting values and for each change put new values in another array.....etc.

Has anyone ever done this before and in that case was it succesfull and how? Is it at all possible?

Will be very glad for some kind of input on this
 
I think that the easiest thing for you to do in this situtation is to look at all of the inputs on the page and find the ones you need to handle...

allInputs = document.getElementsByTagName(&quot;input&quot;)
for (x=0; x<allInputs.length; x++){
//look at them here...
}

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
Thanks for the speedy reply.

Your suggestion takes care somewhat of the amount of elements to keep track on. Havent had time to test it, but it seems so.

But how do I proceed from here? Should I give up the solution of arrays on parent?
 
The difference between the fields is their type, you can use Javascript to test the type of field that you have so you could use that as well when linking fields.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top