• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 415
  • Last Modified:

Passing variable thru JS

hi experts,

I need to pass this 2 values in JavaScript:

..
<INPUT type="hidden" id="city" name="city" maxLength=20   value="<%=city%>">
<INPUT type="hidden" id="state" name="state" maxLength=20  value="<%=state%>">

<% if (rs.getString("ZIP")!= null) {
zip = rs.getString("ZIP");
zip_ID = rs.getString("ZIP_ID");
 
%>
    <a href="javascript:passData(zip, zip_ID)"><%out.print(zip);  }%></a></td>                              
</TD></TR>
<%} %>

function passData(??????, ???)
{
window.opener.document.getElementById("state").value =document.getElementById("state").value;
window.opener.document.getElementById("city").value =document.getElementById("city").value;
window.opener.document.getElementById("zip_id").value =????How to pass ZIP_ID value here ???
window.opener.document.getElementById("zip").value = ????How to pass ZIP value here ???

 self.close();
}




<a href="javascript:passData(zip, zip_ID)"> When view page source I was able to see values <a href="javascript:passData(5,88989)">
But dont know how to pass to JS function and assign there ....
THX
PH
0
princehyderabad
Asked:
princehyderabad
2 Solutions
 
boonlengCommented:
Just point the value to the function parameter. Once the link clicked, the value will be pass as the parameters on the function

function passData(zip, zip_id)
{
window.opener.document.getElementById("state").value =document.getElementById("state").value;
window.opener.document.getElementById("city").value =document.getElementById("city").value;
window.opener.document.getElementById("zip_id").value =zip;
window.opener.document.getElementById("zip").value = zip_id;

 self.close();
}
0
 
Ryan ChongCommented:
and looks like line:

<a href="javascript:passData(zip, zip_ID)"><%out.print(zip);  }%></a></td>  

should be as:

<a href="javascript:passData('<%=zip%>', '<%=zip_ID%>')"><%=zip%></a></td>  

?
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now