Jump to content


Javascript help


3 replies to this topic

#1 Stoole

    Young Padawan

  • Members
  • Pip
  • 9 posts

Posted 15 November 2007 - 06:01 PM

Hi!

I'm quite new to javascript coding in I need some help from you. I've coded this code so far;

Quote

<script type="text/javascript">

function tag_url() {

var enterURL = prompt("Enter URL", "http://");

}

</script>

<input type="button" value="URL" onClick="tag_url()">

</ br></ br>

<textarea id="text" rows="10" cols="60">

</textarea>

and now i wanna code that the user input from java prompt will be inserted into a textfield.

Thanx for your help :popcorn:

#2 curthard89

    Young Padawan

  • Members
  • Pip
  • 226 posts

Posted 16 November 2007 - 03:19 AM

simple way would just be

<script type="text/javascript">

function tag_url() {

var enterURL = prompt("Enter URL", "http://");

document.getElementById('text').value += enterURL;

}

</script>

#3 Stoole

    Young Padawan

  • Members
  • Pip
  • 9 posts

Posted 16 November 2007 - 11:26 AM

What about if I wanna make that output from prompt will be sorunded with [] tags.

Quote

Example: [link] output from prompt [/link]

Edited by Stoole, 16 November 2007 - 11:29 AM.


#4 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 16 November 2007 - 03:40 PM

If you're looking for how to make bbcode prompts, there are dozens of tutorials on how to do that. You should use the tutorial search/google if that's what you want.

The wrapping of a string in another string is also basic javascript. If you managed to write what you did above, you should be able to do simple string modifications also.

But just because i'm nice, javascript uses the '+' operator for string concatenation.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users