riffraff5
asked on
populate text box
What I need to do is allow user to populate a text box based on link or graphical selection prior to submitting without a page reload.
For example if the user clicked A, then B then C....the value of name would be ABC
<form action="test" method="post">
<input type="text" name="name" value="">
<input type="submit" value="Submit">
</form>
<a href="">A</a> |
<a href="">B</a> |
<a href="">C</a> |
For example if the user clicked A, then B then C....the value of name would be ABC
<form action="test" method="post">
<input type="text" name="name" value="">
<input type="submit" value="Submit">
</form>
<a href="">A</a> |
<a href="">B</a> |
<a href="">C</a> |
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<script language="javascript">
function add_char(char)
{
form1.textname.value = form1.textname.value + char;
}
</script>
<form name="form1" action="test" method="post">
<input type="text" name="textname" value="">
<input type="submit" value="Submit">
</form>
<a href="#" onClick="add_char('A');">A </a> |
<a href="#" onClick="add_char('B');">B </a> |
<a href="#" onClick="add_char('C');">C </a> |
function add_char(char)
{
form1.textname.value = form1.textname.value + char;
}
</script>
<form name="form1" action="test" method="post">
<input type="text" name="textname" value="">
<input type="submit" value="Submit">
</form>
<a href="#" onClick="add_char('A');">A
<a href="#" onClick="add_char('B');">B
<a href="#" onClick="add_char('C');">C
If a user clicks a href he actually leaves the page. So there is no simple way it can be done only using javascript.
So i would like to know if the href click would take the user out of the page??
So i would like to know if the href click would take the user out of the page??
Glad to be of help, riffraff5.
A hyperlink need not always take you do a different page. A hyperlink can be used to go to the top of the page, a quick jump location etc. the '#' makes it go nowhere.
Cheers
-VM
A hyperlink need not always take you do a different page. A hyperlink can be used to go to the top of the page, a quick jump location etc. the '#' makes it go nowhere.
Cheers
-VM
2) On every Onlick event of Href Append the Href's id/ Name / code to the global
3) Assign that global variable to a hidden variable before submitting the form
Regards,
Hope it Helps