Plis need help with Ajax, php?
-
I have a question about ajax, php so plis help me anyone. So i have created a form it has two id nume and mesaj i also conect to my database and with while loop so that i could display couple of forms with different values from database: <?php $result1=mysql_query("SELECT * FROM post",$pr); $myrow2 = mysql_fetch_array($result1); do { ?> <div id="txtHint"><b>Person info will be listed here.</b></div> <form method="post" name="form1" onsubmit="ajaxrequest('test_post.php'); return false;"> Your name: <input type="text" name="nume" id="nume" value='<?php echo $myrow2["text"]; ?>' /> Your message: <input type="text" name="mesaj" id="mesaj" value='<?php echo $myrow2["text2"]; ?>'> <input type="submit" value="Send" onmousemove="showUser(9)"/> </form> <?php } while($myrow2 = mysql_fetch_array($result1)); ?> And here the ajax code: <script type="text/javascript"><!-- function get_XmlHttp() { var xmlHttp = null; if(window.XMLHttpRequest) { xmlHttp = new XMLHttpRequest(); } else if(window.ActiveXObject) { // for Internet Explorer 5 or 6 xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } return xmlHttp; } function ajaxrequest(php_file) { var request = get_XmlHttp(); var nume = document.getElementById('nume').value; var mesaj = document.getElementById('mesaj').value; var the_data = 'nume='+nume+'&mesaj='+mesaj; request.open("POST", php_file, true); // sets the request request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); request.send(the_data); } --></script> The problem is that it display only first form values when i submit, when i submit other forms button it still submits first form values so plis help me i need help badly, some example code would be nice.
-
Answer:
I am sorry, but your code is so badly organized that I can't follow it. Please, LEARN how to sructure your code properly. There are 4 basics structures available at http://web2coders.com, freephp scripts, basic lessons 1 to 4. Learn from them. Good luck.
MailL at Yahoo! Answers Visit the source
Related Q & A:
- How to upload file using ajax php?Best solution by Stack Overflow
- I need help on what I need to buy or do.Best solution by Yahoo! Answers
- I need help with some horse questions, can you help me.Best solution by Yahoo! Answers
- I did something really bad and now i need help please help me.Best solution by Yahoo! Answers
- What sort of opportunities are there to help people in Africa or places where people need help?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.