Jump to content


select and copy data by a click

  • Please log in to reply
3 replies to this topic

#1 miz_luvly@hotmail.com

  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 09 June 2006 - 10:41 AM


I have a form where reps add reports. I also have a link where reps can lookup account no by entering their name and customer name. once account no is found they have to type that number in the form. Is possible to auto-select account no from lookup page and add it to the account no textbox on the form.
i have added a link in account lookup page but not sure what to do next to make it work.

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Account No|Customer Name |Town | Post Code |Rep Name | Click to add
xxxx | abc |xyz | xxxx xxx |aaaaa |ADD [/quote]

here is the code:
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]

require 'conn.php';

if (($_GET['customer_name']!=""))
$sql = "select * from rep_table WHERE repname like '".$_GET['repname']."' and";
if ($_GET['customer_name']!="")
$sql = $sql." CUSTOMER_NAME LIKE '".$_GET['customer_name']."%'";

$result = mysql_query($sql);
if (!$result)
echo 'Could not run query: ' . mysql_error();

echo "<table border=1 align='center' class='rep' width ='' " .
echo "<tr><th class='searchHeader'><caption><b> Search Results</b></caption> </th></tr>\n";
echo "<tr><td align='center'><b>Account No:</td><td><b>Customer Name:</td><td><b>Town:</td><td><b>Post Code:</td><td><b>Rep Name:</b></td><td>Click to add</td></tr>";

if ($result and !mysql_num_rows ($result))
echo "<tr class='row1'><td colspan='4'>No results found that match the ";
echo "search term(s)";
echo '</br><font color="red">please go back and try again</font></br>';

while($row = mysql_fetch_array($result, MYSQL_BOTH))

echo "<tr><td align='center'>$ACCOUNT_NO</td>
<td><a href='repform.php?cmd=update&account_no=$ACCOUNT_NO'>ADD</a></td></tr>";
echo "</table>";
?> [/quote]

thanks in advance

#2 wisewood

  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts
  • LocationRotherham, England

Posted 09 June 2006 - 11:11 AM

<input type="text" value="<?php echo $ACCOUNT_NO ?>">
wisewood: proven fact, I am both wise, and wooden.

#3 joquius

  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts

Posted 09 June 2006 - 11:17 AM

Hi just some general points first.

There are quite a few issues with the _GET verification. First of all you should always ?isset() _GET vars. The second if query is the same as the first so it should be emmited. Aslo "AND" should be moved to the optional sql as it will make an open query if the optional is not appended.

I will not go into the code too much, but what you could can do is simply add a ?user=<?=$user?> on the redirect back to the other page, or added the user lookup on the same page (hidden until $_GET['search']) and add it with java onclick="documentgetElementById('user_name').value="<?=$user_name?>";"

here's a quick run over what I stated in a verbal form:

<first page>
<? if (isset ($_GET['add_account'])) include ("serachform.php"); ?>
in searchform.php,
onclick add, value of user in form on first page is set to the value from search query

I am assuming this is what you meant by autoselecting yes?

#4 .josh

  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 09 June 2006 - 04:54 PM

i think what he meant was when the user selects account info based on the account number in order to add/edit account information, he wants the known value (the account number) to be automatically put as the value in the text input field (see Wisewood's post)
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users