javascript - Save data from an imagemapster script to a mysql db -


so, problem following: made imagemapster map of image of teeth, , want select more 1 tooth, , bridges between teeth, , click button, make verifications, , if good, save chosen teeth , bridges in mysql database.. thing is, don't know how it.. im new this, , know bit of php , html... easiest / simplest way of doing this? read ajax seemed complicated learning how it.. read hidden forms? tried didn't work, did wrong.. simple mapster script have now..

    <script>     $(document).ready(         function ()         {             $('#img').mapster(             {                 mapkey: 'tooth',                 fillcolor: '118f3b',                 fillopacity: 0.5,                 render_highlight:                 {                     fillcolor: '78e99d',                     fillopacity: 0.5                 },             });         }     );     </script> 

edit: tried now, , kind of worked.. seems current clicked map doesnt count, on second click first 1 saved.. e.g click on 1 , 2, 1 shown.. click 3 , 1 , 2 shown.. problem here: imagemapster (javascript)- "onclick" function wont work properly

    onclick: function(data)     {         var test = image.mapster('get');         document.cookie = "cookie_with_info = " + test_var;     } 

i managed solve problem.. maybe it's not best solution, it's working! so, after seeing this: http://www.outsharked.com/imagemapster/examples/usa.html saw down part showing selected area , checked code , got answer, basic script:

<script> var image = $('#teeth_map');  $(document).ready(function () {         image.mapster(         {             mapkey: 'tooth',             fillcolor: '118f3b',             fillopacity: 0.5,             render_highlight:             {                 fillcolor: '78e99d',                 fillopacity: 0.5             },         });          function showteeth(){             $("#send_button").bind("click", function (e)             {                 e.preventdefault();                 var test = image.mapster("get");                 document.cookie = "teeth_cookie = " + test;             });         }          showteeth(); }); </script> 

$('#teeth_map') map made of image, $("#send_button") id of send/save button, now, script saved clicked areas cookie, need php read it:

<?php if(isset($_cookie['teeth_cookie'])) {     $cookie = $_cookie['teeth_cookie'];     echo "the selected areas are: " . $cookie; } else     echo "text show there no cookies!"; ?> 

now after this, seems extremely simple hard (for me), variable $cookie has values of selected areas of image map..


Comments

  1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog.
    Really very informative post you shared here. Kindly keep blogging.
    If anyone wants to become a Front end developer learn from Javascript Online Training from India .
    or learn thru JavaScript Online Training from India.
    Nowadays JavaScript has tons of job opportunities on various vertical industry. ES6 Training in Chennai

    ReplyDelete

Post a Comment