Copy link to clipboard
Copied
I'm making a website for users where they can creat customize logos. For this I need a facility to add dynamic text from text boxes which the user will fill in and the text should then appear on the the selected image. Is there any way, say for Javascript, through which I can fulfill the above scenario? Would appreciate any suggestions of how i could do this.
My HTML so far is:
<html>
<body>
<input type="text" id="submit"/>
<img src=<?php echo $image; ?> id="toChange" alt="pic" width="60" height="60" />
</body>
and my jQuery:
$('#submit').change(function() {
$('#toChange').text( $('#submit').val());
});
but I haven't been succeed so far.
1 Correct answer
Does this help:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script>
$(document).ready(function(){
$('.submit').click(function(){
var text = $('.text').val();
$('.product_text').html('<p>' + text + '</p>');
return false;
});
});
</script>
<style>
* {
box-sizing: border-box;
}
img {
max-width: 100%;
height: auto;
}
body {
font-family: helvetica, sans-serif;
font-size: 14px;
color: #999;
}
.product_wrapper {
width: 300
...Copy link to clipboard
Copied
Does this help:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script>
$(document).ready(function(){
$('.submit').click(function(){
var text = $('.text').val();
$('.product_text').html('<p>' + text + '</p>');
return false;
});
});
</script>
<style>
* {
box-sizing: border-box;
}
img {
max-width: 100%;
height: auto;
}
body {
font-family: helvetica, sans-serif;
font-size: 14px;
color: #999;
}
.product_wrapper {
width: 300px;
margin: 0 auto;
}
.product_image {
background-color: #f2f2f2;
width: 300px;
margin: 0 auto;
position: relative;
}
.product_text {
position: absolute;
bottom: 20px;
width: 100%;
text-align: center;
background-color: rgba(0, 0, 0, 0.5);
color: #fff;
}
.product_text p {
margin: 0;
padding: 15px 20px;
}
.input_text {
margin: 0;
background-color: #f2f2f2;
padding: 20px;
border: 1px solid #ccc;
}
label {
font-size: 16px;
padding: 0 0 15px 0;
}
.text {
width: 100%;
padding: 10px;
font-size: 14px;
margin: 15px 0;
}
.submit {
background-color: #666;
border: none;
padding: 10px 15px;
color: #fff;
text-transform: uppercase;
}
</style>
</head>
<body>
<div class="product_wrapper">
<div class="product_image">
<div class="product_text"></div>
<!-- end product_text -->
<img src="http://images.all-free-download.com/images/graphiclarge/monarch_butterfly_on_flower_196546.jpg" alt="pic" />
</div>
<!-- end product_image -->
<form class="input_text" name="input_text" action="">
<label for="text">Insert Text<br />
<input class="text" type="text"><br />
<input type="submit" class="submit" value="submit" />
</label>
</form>
</div>
<!-- end product_wrapper -->
</body>
</html>

