Passing variable thru JS

Posted on 2006-05-11
Last Modified: 2010-04-01
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>                              
<%} %>

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 ???


<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 ....
Question by:princehyderabad
    LVL 14

    Assisted Solution

    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;

    LVL 48

    Accepted Solution

    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>  


    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    maven scope 1 118
    if statement not resolving in my code 5 39
    maven set up 2 86
    spring example non maven 4 58
    It Is not possible to enable LLDP in vSwitch(at least is not supported by VMware), so in this article we will enable this, and also go trough how to enabled CDP and how to get this information in vSwitches and also in vDS.
    Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now