Forum Moderators: open

Message Too Old, No Replies

Passing variables to PHP using Javascript

using form button to add text boxes

         

mattennant

9:27 am on Dec 1, 2007 (gmt 0)

10+ Year Member



Hello
I'm trying to enable users to add form text fields to a page using a form button without reloading the page. Is there a way i can do this without resending the page and using $_GET.

I have managed to pass the php variable to javascript as below


<script language=JavaScript>
var a = <?PHP echo "$number";?>
a+=1;
document.write(a) //will produce 6
</script>

but i need this to work the other way round with the button click adding 1 to $number. Do i need to be looking into ajax?

Any help much appreciated

mattennant

10:14 pm on Dec 3, 2007 (gmt 0)

10+ Year Member



i

eelixduppy

10:29 pm on Dec 3, 2007 (gmt 0)



>> Do i need to be looking into ajax?

Yes. Here's a good place to start: [news.php.net...]

mattennant

9:44 am on Dec 5, 2007 (gmt 0)

10+ Year Member



thanks, very useful tutorial

mat