Search code examples
javascriptphpjqueryhref

pass the value to a hyperlink


I have a page with content 2 date pick list for me to pick the start date and end date.At the same page i have a Excel image which will ref to another php page once i click it. How i going to pass the value in date pick list to another php ? There is no problem if i click submmit form. But i more prefer to use . Is that i need to use javascript or jquery ?

<html>
<head>
<script type="text/javascript"  src="../../Scripts/jquery-1.4.1.js"></script>
 <script type="text/javascript" src="../../Scripts/jquery-1.4.1.min.js"></script>
 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
</script>
<script type=”text/javascript” src=”jquery-1.3.2.min.js”></script>
<script id="source" language="javascript" type="text/javascript">

http://www.scriptcase.net/scriptcase-samples/php-form/master-detail/

$(document).ready(function(){


 });

</script>
</head>
<body>
<form name="purchase" method="post" action="purchaseReportExcel.php">
<div  style="width: 80%; margin-left: 10%;">

<table>
<tr><b>Purchase Report</b></tr>

<tr>
<td>Purchase created date (start date)</td>
<td><input type="date" id="Sdate" name="Sdate" /></td>
<td>Date format: (yyyy--mm--dd)</td>
</tr>

<tr>
<td>Purchase creat date (end date)</td>
<td><input type="date" id="Edate" name="Edate" /></td>
<td>Date format: (yyyy--mm--dd)</td>
</tr>



 <div  style="width: 80%; margin-left: 10%;">
<!-- -->
 <div style="width: 25%; height: 150px; float: right;">


<input type="submit" value="submit" name="submit" />
</br>
<a href="purchaseReportExcel.php?Sdate=<?php $_REQUEST['Sdate']; ?>&amp;Edate=<?php      $_REQUEST['Edate']; ?> "  title="purchase report"/><img src="excel3.png" title="purchase report"/></a>

</div>
</div>
<table>
</div>
</form>
</body>
</html>

appretiate your help.Thabks


Solution

  • Try this

    <script>
    
    function sent_date()
    {
     sdate=document.getElementById("Sdate").value;
     edate=document.getElementById("Edate").value;
     window.location=('purchaseReportExcel.php?Sdate='+sdate+'&Edate='+edate);
    }
    </script>
    
    <a href="#" onclick="return sent_date();" title="purchase report"/><img src="excel3.png" title="purchase report"/></a>