Computing.Net > Forums > Windows Vista > make a hidden button + textbox

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

make a hidden button + textbox

Reply to Message Icon

Name: You know who we are.
Date: July 25, 2009 at 17:00:40 Pacific
OS: Windows Vista
CPU/Ram: 2GB
Product: Microsoft / Vista
Subcategory: General
Comment:

Hello I am making a webpage and I want a textbox and a submit button to appear when I different button is clicked here is the code I am using:


<html>
<head>
<title>test</title>

<script type="text/javascript">
function addInput(f,a) {
var aInputs=f.getElementsByTagName('textarea');
for(var i=0; i<aInputs.length; i++) {
if(aInputs[i].className=='hide') {
aInputs[i].className='';
break;
}
}
}
</script>

<style type="text/css">
input {display:block;}
.hide {display:none;}
</style>


</head>
<body>


<form action="#" name="form1">
<div>
<textarea id="box1" cols="75" rows="5" class="hide" type="text"
name="box1"></textarea>
<button type="button" id="box2" class="hide"
name="box2">Confirm</button>
<button type="button"
onclick="addInput(this.form);">Comment</button>
</div>
</form>

</body>
</html>


I don't know how to make the button appear, can anyone help please, or if I could make the comment button work to make the textbox appear and then make it be comment the second time it is pressed, is that possible? Or could I get the button to work to, maybe something like this:

var aInputs=f.getElementsByTagName('textarea' 'button');

I don't know, Please help, I have seen these kind of things work before on facebook and some other sites, but how?



Sponsored Link
Ads by Google

Response Number 1
Name: anmor
Date: July 26, 2009 at 14:13:30 Pacific
Reply:

You would do better to post this in the Web Development forum.


0

Response Number 2
Name: You know who we are.
Date: July 26, 2009 at 16:05:26 Pacific
Reply:

I know, but this site was being stupid and only giving me an
option of about 5 forums and they were all hardware thing
so I put it in this.


0

Response Number 3
Name: Fist (by fmwap)
Date: July 28, 2009 at 17:56:41 Pacific
Reply:

Hey, answering your previous question from here: http://www.computing.net/answers/we...

jQuery is just a single javascript file that you include in a <script> tag, you can grab the latest version from here:
http://code.google.com/p/jqueryjs/d...

In jquery you can target dom elements via CSS selectors, and that's really where the beauty of it lies - you can target elements using good ole CSS.

So, the page would look something like this:
<html>
<head>
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript">
//fires after body loads
$(function() {
//When the id=clickme_button is pressed
$('#clickme_button').click(function() {
//Toggle visibility on the .hideme items
$('.hideme').toggle();
});
});
</script>
<style type="text/css"><!--
.hideme { display: none; }
--></style>
</head>
<body>
<input type="button" id="clickme_button" value="Click me" />

<input class="hideme" type="button" value="Some value" />
<textarea class="hideme"></textarea>
<p class="hideme">All the elements with a CSS class of hideme get selected</p>
</body>
</html>

The base download can do a lot, check the documentation for examples here:
http://docs.jquery.com/Main_Page


0

Response Number 4
Name: You know who we are.
Date: July 29, 2009 at 03:27:01 Pacific
Reply:

Thank you so much, that may be one of the best answers I have gotten from this site, but one more thing, what if I want to or more of those kind of buttons on the same
page, I don't want the first button to control everything on the page, just some of them, is that possible?


0

Response Number 5
Name: You know who we are.
Date: August 10, 2009 at 18:59:01 Pacific
Reply:

Never mind, I figured out how to do more than one, but I uploaded my files and for some reason it doesn't work. is there a way to do it without using jQuery and using just
plain javascript? go to this site http://glitch.vndv.com/ it is the code you posted up here, I put the files in the right directory but it just doesn't work.


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon

Problem opening 2nd windo... new folder with japanese ...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Windows Vista Forum Home


Sponsored links

Ads by Google


Results for: make a hidden button + textbox

my emachine computer makes a loud noise www.computing.net/answers/windows-vista/my-emachine-computer-makes-a-loud-noise/5634.html

Making a USb port turn on??? www.computing.net/answers/windows-vista/making-a-usb-port-turn-on/1972.html

Hidden Partition www.computing.net/answers/windows-vista/hidden-partition/4550.html