riT-k0MA Posted March 6, 2009 Share Posted March 6, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/148238-starting-a-php-function-by-clicking-a-button-without-reloading-the-page/ Share on other sites More sharing options...
Maq Posted March 6, 2009 Share Posted March 6, 2009 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! Quote Link to comment https://forums.phpfreaks.com/topic/148238-starting-a-php-function-by-clicking-a-button-without-reloading-the-page/#findComment-778213 Share on other sites More sharing options...
riT-k0MA Posted March 6, 2009 Author Share Posted March 6, 2009 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"?>"; "; Quote Link to comment https://forums.phpfreaks.com/topic/148238-starting-a-php-function-by-clicking-a-button-without-reloading-the-page/#findComment-778291 Share on other sites More sharing options...
JonnoTheDev Posted March 6, 2009 Share Posted March 6, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/148238-starting-a-php-function-by-clicking-a-button-without-reloading-the-page/#findComment-778326 Share on other sites More sharing options...
riT-k0MA Posted March 6, 2009 Author Share Posted March 6, 2009 Ok, I'll give it a try on monday. Thanks. Anyone else got some ideas I could also try? Quote Link to comment https://forums.phpfreaks.com/topic/148238-starting-a-php-function-by-clicking-a-button-without-reloading-the-page/#findComment-778332 Share on other sites More sharing options...
kenrbnsn Posted March 6, 2009 Share Posted March 6, 2009 AJAX responses don't have to be sent back as XML, you can send back plain text, HTML, or JSON encoded arrays. I use AJAX all the time and I don't think I've ever returned an XML string. Ken Quote Link to comment https://forums.phpfreaks.com/topic/148238-starting-a-php-function-by-clicking-a-button-without-reloading-the-page/#findComment-778377 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.