0

am i doing this right? i want to put the value of "i.src" into the input and then display the generated image on the other page using the post command

  $('#create').bind('click', function(e){
    var datapair = $sigdiv.jSignature("getData", "image") 
    var i = new Image()
    i.src = "data:" + datapair[0] + "," + datapair[1] 
    $('#displayarea2').empty();
$(i).appendTo($("#displayarea2")); // append the image (SVG) to DOM.
    $getElemenById('sig').value = i.src;
$document.getElemenById('sig').value = i.src;//store the value of i.src to input
alert("done1");
})

<input type="image" id="sig" name="sig" />

       <?php echo $_POST["sig"]; ?>
Link
  • 303
  • 1
  • 5
  • 13

1 Answers1

2

You can set the value of a hidden field :

<input type=hidden id=sig name=sig>


document.getElemenById('sig').value = myImage.src;

But is it advisable ? This is a big string, don't you have other solutions than to pass it to the server just to have it back ? If it's server generated, can't you store it on the server ? Or use ajax so you don't replace the whole page and so you keep the image browser-side ?

Denys Séguret
  • 372,613
  • 87
  • 782
  • 758