Reputation: 174
<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
Upvotes: 1
Views: 36048
Reputation: 181
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>
Upvotes: 0
Reputation: 7762
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);
Upvotes: 1
Reputation: 476
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
Upvotes: 0
Reputation: 590
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>"
Upvotes: 0
Reputation: 46900
<? 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>
Upvotes: 0