Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

put a value in "Text button"

Status
Not open for further replies.

Keendev

Technical User
Joined
Jan 23, 2006
Messages
106
Location
PH
Hi guys,

I have a text button, and I wanted to put value on it so that when the button is click, the button value will be displayed in form textbox on the same page.

is this possible ??
ex. 1.text button display : "Main Group"
2.text button value : "/maingroup/"
3.form text box default value=""
4.when text button is clicked ,"/maingroup/" text value will be displayed on form textbox.

thanks.
 
It is NOT possible for a button value to be different from its display text. However, this should give you a general idea of how to do the 'setting':

Code:
<html>
<body>
	<form>
		<input type="button" value="/maingroup/" onclick="this.form.elements['someField'].value = this.value;" />
		<input type="text" name="someField" value="" />
	</form>
</body>
</html>

Hope this helps,
Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Hi,

I edited your code. need help once more...pls check

Code:
<html>
<body>
    <form>
        <a href="#" onclick="this.form.elements['someField'].value = this.value;">
        <input type="text" name="someField" value="" />
        <br>
        <br>
        Main Group</a>
		<input type="hidden" name="txtvalue1" value="/maingroup/" onclick="this.form.elements['someField'].value = this.value;" />
		<input type="button" value="Submit" onclick="this.form.elements['someField'].value = this.form.txtvalue1.value;" />
		
		<br>
		<br>
	    <a href="#">Sub Group</a></a>
		<input type="hidden" name="txtvalue2" value="/subgroup/" onclick="this.form.elements['someField'].value = this.value;" />
		<input type="button" value="Submit" onclick="this.form.elements['someField'].value = this.form.txtvalue2.value;" />
    </form>
</body>
</html>

I hope we can erase the "Submit" button and just use the text link.

thanks again. :-)

 
This will do the same thing but using links, not buttons:

Code:
<html>
<body>
    <form>
        <input type="text" name="someField" value="" />
	</form>

	<br />
	<br />
	<span onclick="document.forms[0].elements['someField'].value = '/maingroup/';" style="cursor:pointer;">Main Group</span>

	<br />
	<br />
	<span onclick="document.forms[0].elements['someField'].value = '/subgroup/';" style="cursor:pointer;">Sub Group</span>
</body>
</html>

Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
ow sorry for that misusage , text button ..it should be text link.

is it possible to use the textlink instead of the form button to display the value?

tnx again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top