this.form.name is coming as an object????????????????

Hi
I am using exaclty

onchange="updateName('attrName','attributeType',this.form.action,this.form.name);">

and my produced HTML select object is in a page section which is enclosed by a <form> and </form> tag.

I am getting this.form.name as an object. i have verified it using alert in my js script.
The this.form.name should be a string..

do i need to have a "name" in following line
<html:form action="/POIAddAttribute.do" method="POST">
?????

its urget,,,,,,,please help?

Thanks in advance

regards,
venkat
ramareddyjAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
i think it must be onchange="updateName('attrName','attributeType',this.form.action,this.form.name.value);"

please check & tell.
0
ramareddyjAuthor Commented:
Hi
i tried and it shows the form name is "MAUI ORIENTAL MARKET"
(I have put in alert in my js script which shows this value.)

i have no idea what is it???

regards,
venkat
0
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
tell me something what does your updateName function expects as parameteres & what are you trying to do.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

ramareddyjAuthor Commented:
Actually i am trying to send form........the action is captured from the action defined in
<html:form action="/POIAddAttribute.do" method="POST">

but from where will i get teh name of the form???
thats the problem......i need the form beacuse i need to refresh the page using a java script which takes form as an input

Regards,
venkat
0
ramareddyjAuthor Commented:
my js function is like this


function updateName(name,attributeType,FormAction,FormName)
      {
            alert("1= " + FormAction + "-form name is 2 =" + FormName);
            var attribute = document.forms[1].elements[attributeType];
            if(attribute.selectedIndex >= 0){
                  addrValue = attribute.options[attribute.selectedIndex].innerText;
                  var nameAttribute = document.forms[1].elements[name];
                  nameAttribute.value=addrValue;
            
                  //return false;      
            }
            alert("form action  222222is " + FormAction + "formname is " + FormName);
            document.forms[FormName].action=FormAction;
            alert("form action  666666666666666666s " + FormAction + "formname is " + FormName);
            document.forms[FormName].submit();
            
        

      }
0
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
i think you need to have name attribute in your form defination.

<html:form action="/POIAddAttribute.do" method="POST" name = "FormName">
0
fargoCommented:
Hi,

I don't see the point of using formName and formAction in the javascript u used. If i understood you correctly, you are using one form. Correct??
As you are submitting the same form, why to get the action and submit it??

function updateName(name,attributeType)
     {
          var attribute = document.forms[1].elements[attributeType];
          if(attribute.selectedIndex >= 0){
               addrValue = attribute.options[attribute.selectedIndex].innerText;
               var nameAttribute = document.forms[1].elements[name];
               nameAttribute.value=addrValue;
         
               //return false;    
          }
          document.forms[1].submit();
     }

fargo
0
ramareddyjAuthor Commented:
hey thanks a lot....i got my mistake.......

One another request to u sirr.....

the value which i am selecting from my dropdown (on selection the above function is getting called) ..can i get that value once the page is refreshed.....

regards,
venkat


0
ramareddyjAuthor Commented:
actually i am using this line to fetch the value of teh drop down value(selected value)

String attributeType= (String)pageContext.getAttribute("attributeType");

once the page is refreshed can i get this value??????????

regards,
venkat
0
fargoCommented:
Hi,

when the form is submitted, the attribute value from the drop down box is also getting submitted [selected one].  

If it suits, Keep the page form in session and you need not to worry then. Otherwise pass the attribute value again back to the page from the action and handling remains same.

fargo
0
ramareddyjAuthor Commented:
will   String attributeType= (String)pageContext.getAttribute("attributeType"); not give me the value of the selected item of the drop down.???
0
fargoCommented:
No. pageContext.getAttribute() has nothing to do with your form.

fargo
0
ramareddyjAuthor Commented:
when the page is refreshed the action class is not called........how will sending value form the action class help me???

if it is possible then how should i go abt it???


Thanks a lot in advance sirr..
regards,
venkat
0
fargoCommented:
Hi,

What do u mean when the page is refreshed the action class is not called? If the form is submitted and the action of the form is pointed to the action class, it should be called. Untill unless u have some validation over the form!

Moreover, when u do the refresh or a roundtrip make sure to handle it in action class. What i generally do is to make use of a hidden parameter like follows

<html:form...>
<html:hidden property="action" value="save">
..
</html:form>

When one call a update function with javascript, set this action parameter to say "refresh" like the following

documents.forms[0].action.value="refresh";
documents.forms[0].submit();

In the action class, check if the action value is "refresh". If yes, send it back to the input page. This way, u achieve refresh and flow is kept as clean as possible.

fargo
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ramareddyjAuthor Commented:
i got your point.........and i take my words back which said that "when the page is refreshed the action class is not called"
I am through sirr........

actually i was confused ebcause my jsp contains two actions wchih gets called at two diffeten points.
so a bit confusion was there .

but now i have understood teh concept.

Thanks a lot for your help.
Venkat

0
fargoCommented:
No problem. good that u got the point clear.

regards,
fargo
0
ramareddyjAuthor Commented:
hey,

My requirement is bit changed ...now i am setting the action for drop down change in action class as

String dropDownChangeAction ="updateName(this.form,'" + attributeType+" ','" + actionDropDown+"')";

and now its giving me the same js error that document.forms[] is null or an object

please help..

regards,
venkat
0
fargoCommented:
just a small cross check, i saw in your code

'" + attributeType+" ' // there is a space after attributeType string..check that!
0
ramareddyjAuthor Commented:
Hi ,
i am calling setting this action in action class.

but it is taking a parameter(the value of the selected item of the drop down) as input.

in my jsp  i am using
onchange='<%=dropDownChangeAction%>'>


String dropDownChangeAction ="updateName(this.form,'" + attributeType+" ','" + actionDropDown+"')";

the problem is that i am taking attribute calue in action class but that shold come from drop down at run time......

please show me way out

regards,
venkat
 
0
ramareddyjAuthor Commented:


my js function is

function updateName(name,attributeType,FormAction)
      {
                  
            alert("the form is "+ name);
            var nameObj = name.nameType;
            index = nameObj.selectedIndex;
            if(index >= 0)
            {
                  nameObjValue = nameObj.options(index).value;
                  //name.nameType.value=nameObjValue;

                  var nameAttribute = document.forms[1].elements[name];
                  nameAttribute.value = nameObjValue
                                 }
                                        a lert("form action  222222is " + FormAction + "formname is " + name);
            //document.forms[1].action=FormAction;
            document.forms[1].submit();


the error it is giving is selectedindex is null or an object

regards,
venkat
0
fargoCommented:
Hi,

Some of your code is not clear to me like the following:

what is nameType?
What u r trying to do here  var nameAttribute = document.forms[1].elements[name];

So, as far as i understand, the following piece of code will help u.. Copy the below code in a html page...and check it..

<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script>
function updateName(formname,attributeType,FormAction)
     {
               
          alert("the form is "+ formname.name);
          var nameObj = document.forms[0].elements[attributeType];
          alert("the nameObj is "+ nameObj);
              var index = nameObj.selectedIndex;
            alert("the index is "+ index);
              if(index >= 0)
          {
               nameObjValue = nameObj.options(index).value;

               var nameAttribute = document.forms[0].elements['newname'];
                 alert("the check is "+ document.forms[0].elements['newname']);
               nameAttribute.value = nameObjValue
                 alert("the check is "+ document.forms[0].elements['newname'].value);
              }
          alert("form action  222222is " + FormAction + "formname is " + name);
              document.forms[0].action=FormAction;
              document.forms[0].submit();
      }

      function getSelected( selectbox ) {
            for (i=0;i<selectbox.length;i++)
                  if (selectbox.options[i].selected) {
                        return selectbox.options[i];
                  }
      }

</script>
</HEAD>
<BODY>

<form name="actionForm" action="">
<input type="hidden" name="newname">
<select name="attributeList" id="attributeListId" onchange="updateName(this.form, 'attributeList','actionToActionClass');">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
<option value="D">D</option>
<option value="E">E</option>
</select>

</form>

</BODY>
</HTML>


0
ramareddyjAuthor Commented:
hi

String dropDownChangeAction ="updateName(this.form," + actionDropDown + ")";

in my jsp if i do view source i am getting folowing line

<select name="attributeType" onchange="updateName(this.form,/POIExtDropDownChange.do)">-new-
<option value=" "> </option>

at this line it is giving js error as  : "/" expected

what is the issue??

regards,
venkat

0
fargoCommented:
String dropDownChangeAction ="updateName(this.form," + actionDropDown + ")"; // You are missing the '
TO
String dropDownChangeAction ="updateName(this.form,'"+actionDropDown+"')";

0
ramareddyjAuthor Commented:
hey now i am in another problem.............

i have jsp which shows a  link.
on clicking this link another form is dipalyed on the screen on one of the corner.

now in the form which is in the corner i have a combo box. on selecting anything in the combo i an calling my update function which inturn calls an action class....

since i a using struts framework so i need to mention the <forward > tad in struts-config.xml.

so what should i set the forward tag.

i have tried setting the jsp of the overall page.
i have tried the action of the overall paeg
i have tried the action whcih is called on clicking the link

regards,
venkat


0
fargoCommented:
the forward should be for "Action which causes the load of the original or overall page"
0
ramareddyjAuthor Commented:
but in that case it will not show the corner form.
0
fargoCommented:
you have to handle the show corner form with setting some parameter in the action class.
0
fargoCommented:
here i have objection. I believe, i replied him as required. Points should be awarded to me.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.