Jump to content

How to submit forms in php without refreshing the page


reactor86

Recommended Posts

Finally i did it . I just created 5 new functions and assigned to each button. Thank you all guys for trying to help me, thanks Ken2k7 for tips.Take care

WOW! Um.. not what I had in mind, but if you don't mind having 5 functions for this one feature, then fine with me.

Link to comment
Share on other sites

Well i had no choice ,because of lack of time and knowledge of Java. I wish i could see what you have in your mind, i wonder your way too. Let me clear up what i intend to do. I have 5 buttons in my form.html where each executes a bat file without refreshing the page.When any button is pressed, request is sent to my phpform.php where php compares and recognizes which button was pressed and executes the respective bat file ,also sends a response to my html page. I hope now it's clear. By the way the reason i execute bat files is to send ascii characters to COM1.

Link to comment
Share on other sites

I already know what you wanted to do. And frankly, it's just a lack of programming and *common* knowledge, not JavaScript knowledge. I know a mix of both JavaScript and PHP but this issue really doesn't depend on you knowing those specific languages. Let's not forget this isn't really AJAX we're talking about. The AJAX has been done and it's working. We haven't done a single AJAX thing yet. Everything has just been JavaScript. Now, there's not much difference between JavaScript syntax and PHP, so I don't know why JavaScript would be so hard for you to understand. Perhaps, you're over-thinking. If you look at your get function, you see that no matter what button you press, you're always going to send those data. For example, if you click button4, you're still sending submit1 information from your JavaScript get function. So in your PHP script, the first if statement is *always* true. Why? Because you sent submit1 in your JavaScript poststr even if you didn't click the button.

 

So I mean it's more like common sense more than it is JavaScript-specific.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.