ramareddyj
asked on
this.form.name is coming as an object????????????????
Hi
I am using exaclty
onchange="updateName('attr Name','att ributeType ',this.for m.action,t his.form.n ame);">
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.d o" method="POST">
?????
its urget,,,,,,,please help?
Thanks in advance
regards,
venkat
I am using exaclty
onchange="updateName('attr
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.d
?????
its urget,,,,,,,please help?
Thanks in advance
regards,
venkat
ASKER
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
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
tell me something what does your updateName function expects as parameteres & what are you trying to do.
ASKER
Actually i am trying to send form........the action is captured from the action defined in
<html:form action="/POIAddAttribute.d o" 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
<html:form action="/POIAddAttribute.d
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
ASKER
my js function is like this
function updateName(name,attributeT ype,FormAc tion,FormN ame)
{
alert("1= " + FormAction + "-form name is 2 =" + FormName);
var attribute = document.forms[1].elements [attribute Type];
if(attribute.selectedIndex >= 0){
addrValue = attribute.options[attribut e.selected Index].inn erText;
var nameAttribute = document.forms[1].elements [name];
nameAttribute.value=addrVa lue;
//return false;
}
alert("form action 222222is " + FormAction + "formname is " + FormName);
document.forms[FormName].a ction=Form Action;
alert("form action 666666666666666666s " + FormAction + "formname is " + FormName);
document.forms[FormName].s ubmit();
}
function updateName(name,attributeT
{
alert("1= " + FormAction + "-form name is 2 =" + FormName);
var attribute = document.forms[1].elements
if(attribute.selectedIndex
addrValue = attribute.options[attribut
var nameAttribute = document.forms[1].elements
nameAttribute.value=addrVa
//return false;
}
alert("form action 222222is " + FormAction + "formname is " + FormName);
document.forms[FormName].a
alert("form action 666666666666666666s " + FormAction + "formname is " + FormName);
document.forms[FormName].s
}
i think you need to have name attribute in your form defination.
<html:form action="/POIAddAttribute.d o" method="POST" name = "FormName">
<html:form action="/POIAddAttribute.d
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,attributeT ype)
{
var attribute = document.forms[1].elements [attribute Type];
if(attribute.selectedIndex >= 0){
addrValue = attribute.options[attribut e.selected Index].inn erText;
var nameAttribute = document.forms[1].elements [name];
nameAttribute.value=addrVa lue;
//return false;
}
document.forms[1].submit() ;
}
fargo
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,attributeT
{
var attribute = document.forms[1].elements
if(attribute.selectedIndex
addrValue = attribute.options[attribut
var nameAttribute = document.forms[1].elements
nameAttribute.value=addrVa
//return false;
}
document.forms[1].submit()
}
fargo
ASKER
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
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
ASKER
actually i am using this line to fetch the value of teh drop down value(selected value)
String attributeType= (String)pageContext.getAtt ribute("at tributeTyp e");
once the page is refreshed can i get this value??????????
regards,
venkat
String attributeType= (String)pageContext.getAtt
once the page is refreshed can i get this value??????????
regards,
venkat
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
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
ASKER
will String attributeType= (String)pageContext.getAtt ribute("at tributeTyp e"); not give me the value of the selected item of the drop down.???
No. pageContext.getAttribute() has nothing to do with your form.
fargo
fargo
ASKER
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
if it is possible then how should i go abt it???
Thanks a lot in advance sirr..
regards,
venkat
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
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
No problem. good that u got the point clear.
regards,
fargo
regards,
fargo
ASKER
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
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
just a small cross check, i saw in your code
'" + attributeType+" ' // there is a space after attributeType string..check that!
'" + attributeType+" ' // there is a space after attributeType string..check that!
ASKER
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='<%=dropDownChang eAction%>' >
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
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='<%=dropDownChang
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
ASKER
my js function is
function updateName(name,attributeT
{
alert("the form is "+ name);
var nameObj = name.nameType;
index = nameObj.selectedIndex;
if(index >= 0)
{
nameObjValue = nameObj.options(index).val
//name.nameType.value=name
var nameAttribute = document.forms[1].elements
nameAttribute.value = nameObjValue
}
a lert("form action 222222is " + FormAction + "formname is " + name);
//document.forms[1].action
document.forms[1].submit()
the error it is giving is selectedindex is null or an object
regards,
venkat
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,attrib uteType,Fo rmAction)
{
alert("the form is "+ formname.name);
var nameObj = document.forms[0].elements [attribute Type];
alert("the nameObj is "+ nameObj);
var index = nameObj.selectedIndex;
alert("the index is "+ index);
if(index >= 0)
{
nameObjValue = nameObj.options(index).val ue;
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=F ormAction;
document.forms[0].submit() ;
}
function getSelected( selectbox ) {
for (i=0;i<selectbox.length;i+ +)
if (selectbox.options[i].sele cted) {
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','actionToA ctionClass ');">
<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>
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
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,attrib
{
alert("the form is "+ formname.name);
var nameObj = document.forms[0].elements
alert("the nameObj is "+ nameObj);
var index = nameObj.selectedIndex;
alert("the index is "+ index);
if(index >= 0)
{
nameObjValue = nameObj.options(index).val
var nameAttribute = document.forms[0].elements
alert("the check is "+ document.forms[0].elements
nameAttribute.value = nameObjValue
alert("the check is "+ document.forms[0].elements
}
alert("form action 222222is " + FormAction + "formname is " + name);
document.forms[0].action=F
document.forms[0].submit()
}
function getSelected( selectbox ) {
for (i=0;i<selectbox.length;i+
if (selectbox.options[i].sele
return selectbox.options[i];
}
}
</script>
</HEAD>
<BODY>
<form name="actionForm" action="">
<input type="hidden" name="newname">
<select name="attributeList" id="attributeListId" onchange="updateName(this.
<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>
ASKER
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,/POIE xtDropDown Change.do) ">-new-
<option value=" "> </option>
at this line it is giving js error as : "/" expected
what is the issue??
regards,
venkat
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.
<option value=" "> </option>
at this line it is giving js error as : "/" expected
what is the issue??
regards,
venkat
String dropDownChangeAction ="updateName(this.form," + actionDropDown + ")"; // You are missing the '
TO
String dropDownChangeAction ="updateName(this.form,'"+ actionDrop Down+"')";
TO
String dropDownChangeAction ="updateName(this.form,'"+
ASKER
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
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
the forward should be for "Action which causes the load of the original or overall page"
ASKER
but in that case it will not show the corner form.
you have to handle the show corner form with setting some parameter in the action class.
here i have objection. I believe, i replied him as required. Points should be awarded to me.
please check & tell.