1
 <input type="text" name="a" id="a" />
 <a href="xxx.php?id = <? echo '$data['id']' ?>&mk=">CLICK</a>

Now this is my question that can we pass an input tag value of HTML to 'mk' so that value can be used in the next page for process. Though i have done my project in a different way but still i want to know wether is it possible to do so . I have searched a lot but none of the question is same as i got so plz help me out. And i dnt want to use form so i just want to know can we pass this value using href tag r not.

This is the code i have

<form  method="post">
    <table align="center" bgcolor="#FFFFCC" border="1">
        <tr><th>ID</th><th>PRODUCT</th><th>PRICE</th><th>DATE OF POST</th><th>PHONE NUMBER</th><th>AUTHENTICATE</th></tr>
        <?
        $sel = mysql_query("SELECT * FROM addunauth WHERE adminauthorize = 'uncheck'") or die("CANNOT FETCH DATA FOR ADMIN " . mysql_error());
        if (mysql_num_rows($sel) > 0) {
            while ($data = mysql_fetch_array($sel)) {
                ?>      <tr>
                    <td><? echo $data['id']; ?></td>
                    <td><? echo $data['product_name']; ?></td>
                    <td><? echo $data['product_sp']; ?></td>
                    <td><? echo $data['product_time']; ?></td>
                    <td><? echo $data['phoneNumber']; ?></td>
                    <td><input type="text" name="a" id="a" /></td>


                    <td align="center">
                        <a href="processadminTask.php?id=<? echo $data['id']; ?>&mk=" >
                            AUTHENTICATE
                        </a>
                    </td>
                </tr>
    <?
    }
} else {
    ?>          <tr><td>-</td><td>-</td><td>-</td><td>-</td><td>-</td><td>-</td></tr>

        <? }
        ?>
    </table>

</form>

Now just tell me how to pass the input value

4
  • script.php?key=value will run script.php which can access value by <?php echo $_GET['key']; ?> Commented Jan 10, 2014 at 6:38
  • Chatspeak isn't allowed here. Please take the time to write proper English. Commented Jan 10, 2014 at 6:39
  • can u explain in detail please ? Commented Jan 10, 2014 at 6:40
  • sorry meagar but its urgent so iam typing bit fast Commented Jan 10, 2014 at 6:41

5 Answers 5

1

Your variable not parse inside single quotes. your <? echo '$data['id']' ?> should be <?php echo $data['id'] ?>

 <input type="text" name="a" id="a" />
 <a href="xxx.php?id = <?php echo $data['id'] ?>&mk=">CLICK</a>"
 <a id="link" href="xxx.php?id=111&mk=">CLICK</a>

Edit:- simply add one more hidden fields to store id value as well and get value in js and assign to href

 <input type="text" name="idval" id="idval" value="100" />
 <input type="hidden" name="mk" id="mkval" value="101" />  

Js:-

var idval = $('#idval').val();
var mk = $('#mkval').val();
var link = 'xxx.php?id=' + idval + '&mk=' + mk;

$("#link").attr("href", link);

Working Demo

Sign up to request clarification or add additional context in comments.

3 Comments

@Rohit Dubey: try this it may help you.
thanku!! typed wrongly ... but i just want to know can we pass input value to href r not
Check my demonstration.
0
<? echo '$data['id']' ?>

Is wrong PHP Syntax

Use

<?php echo $data['id']; ?>

Like:

<a href="xxx.php?id=<?php echo $data['id']; ?>&mk=">CLICK</a>

Comments

0

Your

<? echo '$data['id']' ?>

is not correct. You can actually use something like this

<?= $data['id'] ?>

so you'll have

<a href="xxx.php?id = <?= $data['id'] ?>&mk=">CLICK</a>"

Comments

0

I think it is possible with javascript:

 getElementById('id of html input').value

This will get you the input value and then you can assign it to 'mk' So you can check with it

Comments

0

Try this

<?php
$data['id'] = 2;
?>
<html>
 <input type="text" name="a" id="a" />
 <a href="xxx.php?id=<?=$data['id'];?>&mk=">CLICK</a>
 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script >
$(document).ready(function(){

$('a[href]').click(function(event){
    event.preventDefault();
    event.stopPropagation();
    var inputTagID = $('#a').val();
    var hrefVal = this.toString().replace("&mk=", "&mk="+inputTagID); 
    window.location = hrefVal;
});
});
</script>
</html>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.