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.
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
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.
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"
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?
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?
Of course there's http://docs.jquery.com/Main_Page but im sure youve seen that already.