SunQuest
 
           JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old August 23rd, 2004, 10:18 AM
Pineriver Pineriver is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 5 Pineriver User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 32 m 12 sec
Reputation Power: 0
Question Trying to get a name in a function

Hello, I am trying to get the element image_url name to the new_text() function
I dont know how I would do this I am a beginner at javascript.

<script language="JavaScript">
function new_text(field_value){
document.form.+field_value+.value="New Text";
}
</script>

<input name="image_url5" type="text" onclick="new_text(this.value)">
[/code]

The problem is that I have 30 textfields like this with all different names, so that is
why I am trying to use a function. Thanks

Reply With Quote
  #2  
Old August 24th, 2004, 10:29 AM
Jackot29 Jackot29 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: Paris, FRANCE
Posts: 29 Jackot29 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 32 m 10 sec
Reputation Power: 0
Red face Maybe

Why not trying something like :

<script language="JavaScript">
function getName(Field_value) {document.write('<script language="JavaScript">' +
'function newText() {document.form.' + field_value + '.value="NewText";}</script>');}</script>

And calling this two functions :
<input name="image_url5" type="text" onclick="getName(this.value); newText();">


It's a little bite barbarian but, let's try turning around this trick.

Reply With Quote
  #3  
Old August 24th, 2004, 12:06 PM
Jackot29 Jackot29 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: Paris, FRANCE
Posts: 29 Jackot29 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 32 m 10 sec
Reputation Power: 0
Of course, you have already tried :

<script language="JavaScript">
function newText() {document.form.this.value="NewText";}</script>

And :

<script language="JavaScript">
function newText() {Field = this.value;
document.form.Field.value="NewText";}</script>

Or just :

<input name="image_url5" type="text" onclick="this.value='New Text'">

Reply With Quote
  #4  
Old August 24th, 2004, 12:11 PM
Pineriver Pineriver is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 5 Pineriver User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 32 m 12 sec
Reputation Power: 0
Thank you, I got it working.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Trying to get a name in a function


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway