rusty0412
08-18-2003, 03:15 PM
Ok, I am new at JavaScript and today I made this script( it is used as echo "..." in PHP, thats why it has many \),
which is invoked by a button like this:
<input type=\"button\" onClick=\"return list(myForm)\" value=\"List\">
SCRIPT:
<script language=\"JavaScript\">
function list(myForm) {
var total = prompt(\"Enter the number of items you wish\",0)
if( total > 15 || total < 1 )
alert(\"You must provide a valide range(1-15)\")
else {
var comp = \"<ul>\\n\"
var x = 0
while( x < total ) {
var ls = prompt(\"Enter an item:\", \"text\")
if( ls != null) {
comp += \"<li>\"
comp += ls
comp += \"</li>\\n\"
}
x++
}
comp += \"</ul>\"
myForm.info.value += comp
}
myForm.info.focus()
return false
}
function newline(myForm) {
myForm.info.value += \"<br>\"
myForm.info.focus()
return false
}
</script>
But this adds the code to the end. How do I add it where the blink cursor is at?
which is invoked by a button like this:
<input type=\"button\" onClick=\"return list(myForm)\" value=\"List\">
SCRIPT:
<script language=\"JavaScript\">
function list(myForm) {
var total = prompt(\"Enter the number of items you wish\",0)
if( total > 15 || total < 1 )
alert(\"You must provide a valide range(1-15)\")
else {
var comp = \"<ul>\\n\"
var x = 0
while( x < total ) {
var ls = prompt(\"Enter an item:\", \"text\")
if( ls != null) {
comp += \"<li>\"
comp += ls
comp += \"</li>\\n\"
}
x++
}
comp += \"</ul>\"
myForm.info.value += comp
}
myForm.info.focus()
return false
}
function newline(myForm) {
myForm.info.value += \"<br>\"
myForm.info.focus()
return false
}
</script>
But this adds the code to the end. How do I add it where the blink cursor is at?