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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing values from one window to another

Status
Not open for further replies.

indupriya9

Programmer
Joined
Oct 29, 2002
Messages
99
Location
NZ
I have a vbscript code that works fine in IE for passing the values between two windows.

Code:
<script language='vbscript'>
   function selected(strId,strDesc)
      window.opener.frm.<% =request("retobj")%><%=request("idx")%>.value=strId
      window.opener.<%=request("retobj")%>__Display<%=request("idx")%>.innertext=strDesc
      window.close 
   end function
</script>

But I had to make this application comaptible with FF where vbscript doesn't work.

So I modified the above code as this, but it does not work. There must be syntax error somewhere.

Code:
dim ret
dim idy

ret=request("retobj")
idy=request("idx") 

<script language='javascript'>
   function selected(strId,strDesc)
     { 
     
     window.opener.frm.<%=ret %><%=idy %>.value=strId
      window.opener.+<%=ret%>__Display<%=idy%>.innertext=strDesc
      window.close 
	}
</script>

When I see the source via html both look the same as follows:

<script language='vbscript'>
function selected(strId,strDesc)
window.opener.frm.domain0.value=strId
window.opener.domain__Display0.innertext=strDesc
window.close
end function
</script>

<script language='javascript'>
function selected(strId,strDesc)
{

window.opener.frm.domain0.value=strId
window.opener.domain__Display0.innertext=strDesc
window.close
}
</script>

But now when I use the javascript I get a 404 error on the second window instead. Any ideas why my javascript code is not working?

Thanks
ip


 
[tt]<script language='javascript'>
function selected(strId,strDesc) {
window.opener.frm.<% =request("retobj")%><%=request("idx")%>.value=strId;
window.opener.<%=request("retobj")%>__Display<%=request("idx")%>.innerHTML=strDesc;
window.close();
}
</script>
[/tt]
 
Thanks tsuji for your response.

I tried that but still the same result. May be the way I am calling the selected function is wrong. Here is how I am calling the function in an xsl file as follows:

Code:
<tr valign='top' bgcolor='detailcell'>
      <td class='detailcell' style='text-align:left'>
          <a class='nav1'><xsl:attribute name="href">selected("<xsl:value-of select='rId'/>","<xsl:value-of select='Rn_Descriptor'/>")</xsl:attribute><xsl:value-of select="Rn_Descriptor"/></a>
      </td>
   </tr>

Is there a mistake in the above code?
 
I was just translating. But after you saying so, I would beef up the script because it contains shortcut apt for ie-platform only. Try this?
[tt]
<script language='javascript'>
function selected(strId,strDesc) {
window.opener.[blue]document.[/blue]frm.<% =request("retobj")%><%=request("idx")%>.value=strId;
window.opener.[blue]document.getElementById("<%=request("retobj")%>__Display<%=request("idx")%>")[/blue].innerHTML=strDesc;
window.close();
}
</script>
[/tt]
There I suppose the first line frm being the form's name and the child element is referred to by name; and the second line I suppose the element is referred to by id. In case the assumptions are not correct, play with the same referencing scheme. It is more strict in moz.
 
But now when I use the javascript I get a 404 error on the second window instead. Any ideas why my javascript code is not working?

Well, in IE at least you now have [!]two[/!] selected functions - you should remove the VBScript one completely, as IE understand JavaScript.

Hope this helps,
Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Thanks tsuji and Dan for your responses. I have removed my vbscript function and replaced the javascript as suggested by tsuji.

But still the same 404 error comes in the popup window, when I select any row. This is happening in both IE and FF.

What is it that I am doing wrong?

I am referencing those two fields as hidden fields in the main form as follows:

Code:
<span class='readonlyfield' style='width:300px;background=white;font-family:arial;' id='domain__Display0'></span><input type='hidden' id='domain0' name='domain0'/>"

Any ideas?
ip
 
Hmm = perhaps the "<a class='nav1'>" is doing it? You have an anchor with no href... and while I'm not sure what behaviour that should exhibit, it might be your casue.

Try removing the anchor and seeing what happens.

Dan


[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Hi Dan

I removed the anchor tag and instead used 'onclick' as follows:

Code:
         <xsl:attribute name="onclick">selected("<xsl:value-of select='rId'/>","<xsl:value-of select='Rn_Descriptor'/>")</xsl:attribute><xsl:value-of select="Rn_Descriptor"/>

But this doesn't do anything
 
I suspect that's because you're not implementing it properly , although I don't understand XSL at all that well, and so aren't in a good position to tell you how you should be going about it. However, I can suggest that you replace your anchor with a span:

Code:
<span class="nav1"><xsl:attribute>selected("<xsl:value-of select='rId'/>","<xsl:value-of select='Rn_Descriptor'/>")</xsl:attribute><xsl:value-of select="Rn_Descriptor"/></span>

Failing that, I'd ask in the XML forum for how to implement the onclick without using an anchor element.

Hope this helps,
Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Hi Dan

Thanks for your advice. I have placed a query on the XML forum. I noticed in the view source that the href is not getting the quotes right. COuld this be the reason?

This is what I saw in the source of the html.
<a class="nav1" href="selected(&quot;0000000000000165&quot;,&quot;REAL ESTATE PRACTICE AND LAW&quot;)">REAL ESTATE PRACTICE AND LAW</a>


Any ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top