javascript - Click image to call php function -


i need click image , should run php script sets php variable , reloads same page.

i know sounds simple i've tried every different way can think of , i'm guessing it's basic i've missed.

i've tried onclick of image, href , onclick, making image 'submit button' of form etc..

any response appreciated.

<a href="#" class='lang'><img src="/images/flags/it.png" alt="it_it" /></a> <a href="#" class='lang'><img src="/images/flags/fr.png" alt="fr_fr" /></a>      

i want image alt value pass it, how possible please give idea..

try this:

lets php variable want change $my_var:

set this:

if(isset($_get['varvalue']) , !empty($_get['varvalue'])){ //if passed , not empty store $my_var = $_get['varvalue']; } else{ die(''); }//else don't let them display page.   

in image put on click listener hat call function php_var();

in javascript add function:

function php_var(){ location = "?varvalue=the_value_that_you_want_to_set"; } 

and url must when first call page(lets http://www.example.com/script.php?varvalue=the_first_valeu_of_variable).

the function change varvalue value , reload page


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

IIS->Tomcat Redirect: multiple worker with default -