...

View Full Version : Updating textbox with links assitance



MarioPro
12-30-2005, 10:37 PM
Is there a way to do the following in Javascript?

I have a list of words that I whish to convert into links to add to a textbox

$list="Blue; Clear Sky; Erode; Erosion; Pole; Sea; Shadow; Sky; Weather; Wood";

What I need is to get each one as a link


<a href="#" onClick="addToTextbox()">Blue</a>
<a href="#" onClick="addToTextbox()">Clear Sky</a>
<a href="#" onClick="addToTextbox()">Erode</a>

But everytime the user clicks a new word it will be added to the ones already in the textbox, with a " AND " prefix

Thnaks in advance for any help

Mr J
12-31-2005, 10:15 AM
Do You mean something like this?


<script type="text/javascript">


firstRun=0
function addToTextbox(str){

if(firstRun==0){
document.forms["formName"]["t1"].value=str
}
else{
document.forms["formName"]["t1"].value+=" AND "+str
}
firstRun=1
}


</script>


<form name="formName">
<input type="text" name="t1" size=80>
</form>


<a href="#" onClick="addToTextbox('Blue')">Blue</a>
<a href="#" onClick="addToTextbox('Clear Sky')">Clear Sky</a>
<a href="#" onClick="addToTextbox('Erode')">Erode</a>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum