Solved

Naming a form....can I ?

Posted on 1998-09-30
3
155 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
This article will show, step by step, how to integrate R code into a R Sweave document
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

733 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