Jump to content

starting a PHP function by clicking a button, without reloading the page


riT-k0MA

Recommended Posts

Hi

I'm a PHP n00b.

3 days ago I was told to start learning PHP

Yesterday I was told to port a VB app to PHP and to make sure it stays exactly the same.  :(

 

Unfortunately that means having a button in the middle of a form that, when clicked, returns a string.

 

Sadly due to contract restrictions and confidentiality issues I can't even post a single line of the code  :-[

 

This is going to be hard...

 

I have a form, made with tables in tables in tables. (to get it to look identical to the VB form)

In the middle of that form is a textbox and a button. When the button is clicked, without refreshing or navigating away from the page, it needs to call up a blackbox function, which will return a string that needs to be put in the textbox.

Being such a PHP n00b I don't even know enough to successfully google my problem..  ???

 

If I haven't managed to confuse everyone horribly, does anyone know how I can solve this?

I don't care whether the solution involves PHP, javascript, HTML or all three combined, just Please Help Me To Get It Working  ???

 

Thanks a huge amount in advance

 

Link to comment
Share on other sites

Without having to refresh the page, you're going to have to use AJAX.

 

Also, without seeing some code it's hard to help you out a lot ;/

 

I'm not familiar with the blackbox function but if it only returns a string you should be able to successfully get this working. 

 

Maybe someone else has an example of a similar problem, but again, without code it's hard for me to give specific help.  Good luck!

Link to comment
Share on other sites

A blackbox function is any function which you know what you can put in and what comes out, but you know little or nothing about the workings of the function.

 

Unfortunately AJAX is not possible, unless it'll work with Abyss.

THanks for replying, though.

 

On second thought maybe a simple bit of code can help...

(I can post this from home, you see)

 

<?php  /*They say knowing a little about a subject is worse than knowing nothing at all. Someone please tell that to my boss.*/
  echo"<form>";
    echo"[table]";
      echo"[tr]";
        echo"[td]<input type=text size=15>[/td]";
        echo"[td]<input type=[unknown] value=[unknown]t />[/td]"; // must trigger a function to ass text to the textfield
      echo"[/tr]";
    echo"</table>";
  echo"</form>";
echo"?>";

";

Link to comment
Share on other sites

If the string that needs to be returned comes from a database then you have no choice bar AJAX.

Otherwise you could write a javascript function to do it and put an onClick() event handler on the button.

I don't care whether the solution involves PHP, javascript, HTML or all three combined, just Please Help Me To Get It Working

 

If you can implement javascript then you can implement AJAX as it is javascript only responses are sent back in XML.

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.