May 23, 2012, 04:13:34 PM
Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News
: follow us on twitter @dotdragnet
Home
Help
Search
Login
Register
DotDragnet
>
The Tech Side
>
Tech stuff
>
jQuery - textual input => image
Pages: [
1
]
Go Down
« previous
next »
Print
Author
Topic: jQuery - textual input => image (Read 696 times)
Charisma Bypass
Hero Member
Posts: 556
jQuery - textual input => image
«
on:
January 08, 2010, 10:25:45 AM »
Here's one I can't get my head around;
I have a text input in a form. When the user is typing in that box, I want images to appear as he is typing.
Imagine it's for a tshirt product, where the buyer can make a slogan to be printed on it. As he is typing his slogan the letters appear on the tshirt as a visual representation.
Any ideas? TIA
Logged
samhs
Administrator
Hero Member
Posts: 1711
Re: jQuery - textual input => image
«
Reply #1 on:
January 08, 2010, 10:36:53 AM »
$("input").change(function () {
$("#display").html("<div></div>"); //reset the contents of #display to be empty other than a <div>
// look through the contents of the string and load each image accordingly
tmpstring = $(this).val();
for (var i=0;i<tmpstring.length;i++) {
theletter = tmpstring.charAt(i);
$("#display div").append("<img src='"+theletter+".gif' />");
}
});
I've not tested this so it may be broken. You need an input and a div with an id of "display", plus a load of images a.gif, b.gif, c.gif etc etc. Not sure how you'd deal with uppercase letters, numbers or punctuation.
Also this isn't very bandwidth friendly - it loads the images again and again each time you change the word - so you change it from burt to burty and it reloads all the burt letters as well as the y. Just so you know.
HTH
Logged
Loose
adj
a not held together; not fastened or firmly fixed in place
Lose
verb
to misplace something. To fail to keep or obtain something, especially because of a mistake, carelessness, etc.
---
Blog:
www.ohwrite.co.uk
Twitter:
www.twitter.com/samhs
Charisma Bypass
Hero Member
Posts: 556
Re: jQuery - textual input => image
«
Reply #2 on:
January 08, 2010, 10:44:13 AM »
Why DDN is still a beautiful place! Will test it out imminently.
Thank You Sam.
Logged
samhs
Administrator
Hero Member
Posts: 1711
Re: jQuery - textual input => image
«
Reply #3 on:
January 08, 2010, 01:19:39 PM »
Hey - no worries. I hope it works for you.
Logged
Loose
adj
a not held together; not fastened or firmly fixed in place
Lose
verb
to misplace something. To fail to keep or obtain something, especially because of a mistake, carelessness, etc.
---
Blog:
www.ohwrite.co.uk
Twitter:
www.twitter.com/samhs
Pages: [
1
]
Go Up
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
General Category
-----------------------------
=> General Discussion
=> Jee's Forum of Appalling Jokes
-----------------------------
The Creative Side
-----------------------------
=> Arty stuff
=> Photography
=> On the web
-----------------------------
The Tech Side
-----------------------------
=> Tech stuff
=> Hardware & Software
-----------------------------
The Business Side
-----------------------------
=> Anything business related
-----------------------------
The Practical Side
-----------------------------
=> Practical Advice
DotDragnet
>
The Tech Side
>
Tech stuff
>
jQuery - textual input => image
Loading...