Forum     

Go Back   Digit Technology Discussion Forum > Portables, Peripherals and Electronics > QnA (read only)
Register FAQ Calendar Mark Forums Read

QnA (read only) Mods please help transfer the contents of this forum to proper sections. :)


 
 
LinkBack Thread Tools Search this Thread Display Modes
Old 29-06-2007, 11:56 AM   #1 (permalink)
Apprentice
 
Join Date: Jun 2006
Location: India
Posts: 67
Unhappy Javascript - Please help me!!


I am making a small project.. i have some doubt..

I have a HTML text-area box, and a button, when i type in some text in the box say Hello, then when i press the button, the words in the text-area box must become 1Hello1

Can anybody help me with this ?? Plz..

Prasanna.
prasanna7287 is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 29-06-2007, 03:31 PM   #2 (permalink)
Back to School Mr. Bean !
 
mod-the-pc's Avatar
 
Join Date: Apr 2004
Location: Chennai
Posts: 343
Default Re: Javascript - Please help me!!

<HTML>
<BODY>
<FORM NAME=FORM1>
<INPUT TYPE=TEXT NAME=TEXT1 VALUE='HELLO'>
<BR>
<INPUT TYPE=BUTTON NAME=SUBMIT1 VALUE=SUBMIT onClick="document.FORM1.TEXT1.value='1'+document.F ORM1.TEXT1.value+'1';">
</FORM>
</BODY>
</HTML>
__________________
Desktop: P4 2.8E, Intel 865GBF, 512MB Hynix PC3200, Samsung SV1204H 120GB, Samsung SW-248F, Creative Inspire 4400, Samsung 793MB, Compro PVR/FM, WinLIRC

Laptop: HP Pavilion dv8210us
mod-the-pc is offline  
Old 29-06-2007, 05:23 PM   #3 (permalink)
Apprentice
 
Join Date: Jun 2006
Location: India
Posts: 67
Default Re: Javascript - Please help me!!

thanks for the quick reply, but supposing.. in the word Hello, if i am going to highlight/select (using my mouse) only the letters Hello, then i would need the output as 1Hell1o ..

can u get this one done for me mate.. am sorry.. am a n00b at java scripting

Prasanna.
prasanna7287 is offline  
Old 29-06-2007, 06:24 PM   #4 (permalink)
Back to School Mr. Bean !
 
mod-the-pc's Avatar
 
Join Date: Apr 2004
Location: Chennai
Posts: 343
Default Re: Javascript - Please help me!!

Try this,
<HTML>
<script language=javascript>
function getActiveText()
{
totalText = document.FORM1.TEXT1.value;
selectedText = document.selection.createRange().text ;
if (selectedText != '')
{
totalText = totalText.replace(selectedText,'1'+selectedText+'1 ')
document.FORM1.TEXT1.value = totalText;
}
return true;
}
</script>
<BODY>
<FORM NAME=FORM1>
<INPUT TYPE=TEXT NAME=TEXT1 VALUE='HELLO'>
<BR>
<INPUT TYPE=BUTTON NAME=SUBMIT1 VALUE=SUBMIT onClick="getActiveText();">
</FORM>
</BODY>
</HTML>
__________________
Desktop: P4 2.8E, Intel 865GBF, 512MB Hynix PC3200, Samsung SV1204H 120GB, Samsung SW-248F, Creative Inspire 4400, Samsung 793MB, Compro PVR/FM, WinLIRC

Laptop: HP Pavilion dv8210us
mod-the-pc is offline  
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript Help REY619 QnA (read only) 5 21-02-2007 09:31 PM
How to add JavaScript to email? nagarjun_424 Tutorials 4 20-03-2006 08:04 PM
JavaScript help......... shehan9999 QnA (read only) 4 05-12-2004 06:34 PM
JAVASCRIPT how to ... abixalmon QnA (read only) 1 17-09-2004 12:52 AM

 
Latest Threads
- by Sujeet
- by Krow
- by abhidev

Advertisement




All times are GMT +5.5. The time now is 07:57 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2