Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Nov 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Anyone that can help me?

    Good evening,

    I am in the process of my website development and I'm a little stuck.
    I am trying to send a HTML form, without having the page refreshed.
    Here's some code where I can explain what my situation is:

    <Form Name='clickform' Method ='POST'>
    <input
    type='image'
    name='button1'
    src='images/button_1.png'
    onmouseover='this.src='images/button_1.png''
    onmouseout='this.src='images/button_1.png''
    width=27
    hight=31
    />
    </Form>
    That is the HTML code I have for my button, which has the following effect when clicked:

    <?php
    if(isset($_POST['button1_x']))
    {
    echo "button1 has been pressed.<br>";
    }
    ?>
    Now what i'm after is that I want the PHP code to be executed when the button is pressed.
    It's working perfectly as long as the page is refreshed when the button is clicked, however I need the PHP code to be executed without a page refresh.

    I've heard of AJAX and whatnot, not particularly sure how I can use it, I'm a pretty decent PHP coder, know some HTML, but never touched any javascript. Is there any simple way I can accomplish my goal without complicated javascript?

    Thank you.

  • #2
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    Quote Originally Posted by madman_ View Post
    Is there any simple way I can accomplish my goal without complicated javascript?
    Nope. You'll need to use AJAX.

    http://www.w3schools.com/ajax/

  • #3
    New to the CF scene
    Join Date
    Nov 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Okay, so how would i do this, i see the sample code it provides on your link where it says "Try it yourself", but i'm not sure how i could use this to just send the form. It appears to me that the actual code to display the text is in javascript too. Is it possible to use the javascript to execute PHP code?

    By any chance could you write me a simple piece of code with a HTML form and the php linked to the javascrpt AJAX so it sends the form without a refresh? I'd be ever so grateful, Thank you.

  • #4
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    We've all had to learn it the hard way, so you need to get your hands dirty and start coding and testing. You'll ne'er learn if you don't try. If you get stuck, by all means post your progress code and someone will help, but the initial attempt has to be made by yourself, (unless you want to hire a coder in the relevant section of the forum to do it for you, that is).


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •