TwelvestoneFront End

dhtml to change input box text


Sign in

  • Waiting for Godot ( 730 k posts )
    Just conversation.
  • Thunder Dome ( 23 k posts )
    Photoshop Tennis and Collabs.
  • Photography ( 5.1 k posts )
    For all you shutterbugs, sh...
  • Flash ( 18 k posts )
    ActionScripting to tweens, ...
  • Front End ( 5.9 k posts )
    general front end design an...
  • Back End ( 9.7 k posts )
    serverside scripting, progr...
  • Projects and Theory ( 12 k posts )
    This forum is for discussio...
  • FAQ ( 269 posts )
    All those nagging questions...
  • Design ( 17 k posts )
    graphics & all aspects of g...
  • Purgatory ( 3.6 k posts )
    12stone Jail, feel free to ...
jestros
 
2011-02-11

I figured how to change everything about an input box, but the text! I am working for an onClick event.

I know you can just type in the damn things, but I'm looking for time saver, where you can click 4-5 buttons per box to save time, or just enter your own if it will be non standard. Or click a button, then edit the inserted text.

Technomancer
 
2011-02-12

Assuming you input field has an id attribute:

Old-skool JS in the onClick event of the button

document.getElementById("input1").value = "Your value goes here"

or better would be to define a function that is called from the onClick event:

function setInput(target, newVal) { document.getElementById(target).value = newVal; }

onClick event would like this onClick="setInput('input1',this.value)"

or if you're using a lib like jQuery, assigning each button a class name that is tehj same as the name or id of the input e.g.

Your jQuery will be something like this:

$(document).ready(function() { $(':button[class=".input"]').click(function() { val target = $(this).attr("class"); $("input[id="+target+"]").val($(this).val()); }); });

none of that's tested btw

jestros
 
2011-02-24

Thanks for the help techno. I not smart enough to get it to work. I found something that did pretty much do what I want through.

<!--

function changeDiv(the_div,the_change) { var the_style = getStyleObject(the_div); if (the_style != false) { the_style.display = the_change;

} }

function hideAll() { changeDiv("other","none");
changeDiv("s-xl","none"); changeDiv("s-2xl","none"); changeDiv("s-3xl","none"); } // -->

available sizes:

s-xl

s-2xl

s-3xl

Sizes: Sizes:
Sizes:

Those are the relevant bits. I'm sure it could be much prettier, but that may come in handy to someone.

jamiec
 
2011-02-25

Gosh you really need some jQuery in your life.

This would have been

$('input:radio').click(function(){ $('#size').val($(this).val()); });

with your radio's having this (example) markup:

and just a single textfield with the id "size"

jestros
 
2011-02-28

You are right Jamie, I need to learn jQ for sure. I'm reading through w3schools.com/jquery, do you have any other source you'd recommend?

cfoley
 
2011-02-28

Originally posted by: jestros You are right Jamie, I need to learn jQ for sure. I'm reading through w3schools.com/jquery, do you have any other source you'd recommend?

HOT XXX jQuery PORN

So many more

jamiec
 
2011-03-01

Of course there's http://docs.jquery.com/Main_Page but im sure youve seen that already.

Sorry, you must be a member to post to a conversation. Either log in or sign up to get involved.
TwelvestoneFront End

dhtml to change input box text