Solved

Naming a form....can I ?

Posted on 1998-09-30
3
146 Views
Last Modified: 2013-12-25
I have this form which I need to associate a name to it. but the only values that the name can have is either a number or a string with spaces. I am passing the name of the form through a parameter to a function. For example:
<form method=post action=... name=<%=str%>>

str : contains either a number or a string with spaces
      ("this is a test")

now when I try to retreive this str value in my function is says the the object is not defined.
this is how i am trying to do it:
function blabla(str,anothersimplestring)
{
   document.forms[str].test.value=anothersimplestring
}
test is the name of a simple input text box. I am trying to display the contents of anothersimplestring in this input box. If anyone can help me, I would appreciate it a lot. Thanks in advance.
0
Comment
Question by:AnitaP
3 Comments
 
LVL 2

Expert Comment

by:chrisbolt
ID: 1828893
Couldn't you just leave out the NAME attribute from the <FORM> tag and use this code instead?:

function blabla(anothersimplestring) {
   document.forms[0].test.value=anothersimplestring
}
0
 

Author Comment

by:AnitaP
ID: 1828894
no I can not. Cause I have multiple forms in my page and I need to send the right information.
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 40 total points
ID: 1828895
1. Get rid of the spaces (f.ex. make them underscores) and use document.this_is_a_test.test.value=anothersimplestring

2. function blabla(str,anothersimplestring) {
      for (i=0,n=document.forms.length;i<n;i++) {
         if (document.forms[i].name == str) {
            document.forms[i].test.value=anothersimplestring;
            break;
         }
    }
}

Michel
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

In this tutorial I will aim to show you how simple is making a small application in WhizBase, how to add, remove and update data in the DB. I will make a small address book application where you can add, browse, update and remove addresses. I wi…
This tutorial will discuss the log-in process using WhizBase. In this article I assume you already know HTML. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you might look at some of my other articles abo…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now