943,790 Members | Top Members by Rank

Ad:
Oct 24th, 2008
0

AJAX & PHP Help

Expand Post »
Was wondering if you could take a look at the attached code.

I have a form that is making a call back to the database and populating search form for parts. As you type in parts, it renders choices (screenshot2 attached). You can then click on a choice and it populates the text box and a button also renders.

You can actually test the script: <URL SNIPPED>

Start typing in "DS12" and then click on one, you will see what I mean (screenshot1 attached).

What I want to do is take the $_GET['id'] and the new part number in the form to another script, right now just putting it into an array. I have a javascript function that sets up the form, called setpartno:


product_search.php
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <?php
  2. echo '<pre>' . print_r($_GET, true) . '</pre>';
  3. ?>
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
  5.  
  6. <html>
  7. <head>
  8. <title></title>
  9. <style type="text/css">
  10. /* ---------------------------- */
  11. /* CUSTOMIZE AUTOSUGGEST STYLE */
  12. #search-wrap input{width:400px; font-size:16px; color:#999999; padding:6px; border:solid 1px #999999;}
  13. #results{width:260px; border:solid 1px #DEDEDE; display:none;}
  14. #results ul, #results li{padding:0; margin:0; border:0; list-style:none;}
  15. #results li {border-top:solid 1px #DEDEDE;}
  16. #results li a{display:block; padding:4px; text-decoration:none; color:#000000; font-weight:bold;}
  17. #results li a small{display:block; text-decoration:none; color:#999999; font-weight:normal;}
  18. #results li a:hover{background:#FFFFCC;}
  19. #results ul {padding:6px;}
  20. </style>
  21. </head>
  22.  
  23. <body>
  24. <h4>Your current Product for this opportunity is <?php echo $_GET['name']; ?></h4><!-- AJAX AUTOSUGGEST SCRIPT -->
  25. <script type="text/javascript" src="lib/ajax_framework.js">
  26. </script>
  27.  
  28. <div id="search-wrap">
  29. <h2>Search for new product</h2><input name="search-q" id="search-q" type="text" onkeyup="javascript:autosuggest()">
  30.  
  31. <div id="results"></div>
  32. </div><script type="text/javascript">
  33. function setpartno(partno) {
  34. document.getElementById('search-q').value = partno;
  35. var e = document.getElementById('results');
  36. e.innerHTML='<input type=submit value="Change Part Number">';
  37. //e.style.display="none";
  38. }
  39. function updatePartName(){
  40. nocache = Math.random();
  41. http.open('get', 'lib/update.php?id='+q+'&partname = '+nocache);
  42. }
  43. </script>
  44. </body>
  45. </html>


I want to pass that Id and part number, as I stated above, to updatePartName(), you will see that below setpartno.

I do not know what to do with this part, I am a little lost. I was wondering if anyone could take a look at it. So I want to click on the button and pass that info ($_GET['id'] and partno (that has been selected) to the update.php script.

I do not know how to pass that in the updatePartName and I also do not know what code I need to do to submit the button, if any or is that code okay?


Man I hope this jibbersh makes sense

Thanks in Advance
~Mike
Attached Thumbnails
Click image for larger version

Name:	screenshot1.jpg
Views:	91
Size:	9.3 KB
ID:	7925  
Last edited by peter_budo; Oct 27th, 2008 at 3:32 am. Reason: URL SNIPPED - user request
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
msimonds is offline Offline
12 posts
since Aug 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: Scriptaculous/Ajax help
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: How to launch pop-up windows using Ajax?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC