简体   繁体   中英

Change php reference when checkbox is clicked

I have an embedded SVG file which I use for SVG icon sprites. Additionally there is a HTML checkbox. If it's clicked I want to change the reference of the embedded SVG file to a different one. I use following phrase to include the SVG file in my HTML file:

  <?php include_once("processed/svg-defs.svg"); ?>

Now I'm searching for a way to change the file with jQuery when the checkbox is clicked.

Try this one.

index.php

 <?php
    if(isset($_REQUEST['file'])){
        if($_REQUEST['file']==2){
        include_once("processed/svg-defs2.svg");    
        }else{
        include_once("processed/svg-defs.svg"); 
        }
    }
    ?>

   <input type="checkbox" onclick="window.location.href='file.php?file=<?php echo (isset($_REQUEST['file']) && $_REQUEST['file']!='')?'':'2'?>'" <?php echo (isset($_REQUEST['file']) && $_REQUEST['file']!='')?'checked':''?>/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM