Unable to get the value from the jsp page.

Hi,

I have developed a JSP, having two split fields seperated by some buttons..The sample code for the same is like this..

(Only the required portion is included)

<script>

function reloadPageOK() {

document.product.method="post"

document.product.action="./TheSamePage.jsp?status=OK"

document.product.submit()

}

function moveValue(from,to) {

if(from.selectedIndex>=0) {

var text=from[from.selectedIndex].text

var length= to.length

to[length]=new Option(text,from.value,false,false)

from.remove(from.selectedIndex)

}

}

function moveAll(from,to) {

if(from.length>0) {

var menutext="";

var i;

var len=from.length

for(i=0;i<len;i++) {

from.selectedIndex=0

menutext=from[0].text

var length= to.length

to[length]=new Option(menutext,from.value,false,false)

from.remove(from.selectedIndex)

}

}

}

></script>

<table border="0" cellspacing="0" >

<tr class="contactDetail">

<td width="10%" class="table_grid1" rowspan="4">

<div class="contactDetail">

<select name="lstProviderLeft" size="7" style="width:111">

<option> PDP</option>

<option> Net</option>

<option> Par</option>

<option> Non-Par</option>

</select>

</div>

</td>

<td width="20%" bgcolor="#FFFFFF" class="contactDetail">

<input type="button" value="&gt;" name="btnLtrProvider" class="button" onclick="moveValue(lstProviderLeft,lstProviderRight)">

</td>

<td width="10%" bgcolor="#FFFFFF" rowspan="4" class="contactDetail"> <font face="Arial, Verdana, Helvetica, sans-serif" size="2" >

<select name="lstProviderRight" size="7" style="width:111"></select>

</font></td>

<tr>

<td width="8%" class="contactDetail">

<input type="button" value=" &gt;&gt; " name="btnLtrAllProvider" class="button" onclick="moveAll(lstProviderLeft,lstProviderRight)" >

</td>

</tr>

<tr>

<td width="8%" class="contactDetail">

<input type="button" name="btnRtlProvider" value="&lt;" class="button" onclick="moveValue(lstProviderRight,lstProviderLeft)" >

</td>

</tr>

<tr>

<td width="8%" class="contactDetail" height="22">

<input type="button" name="btnRtlAllProvider" value=" &lt;&lt; " class="button" onclick="moveAll(lstProviderRight,lstProviderLeft)" >

</td>

</tr>

</table>

<p align = "center"> <input type="button" value="OK" onclick="reloadPageOK()">

The page is working fine. That is we can move the values in the left field to right as single or group.After submitting I need to get the values in the left & right fields respectively.

I have used the method

request.getParameterValues("lstProviderLeft");

and pointed this to an array of strings,but it returns 'null' .

How can I solve the above problem....Post your comments on this issue

Thanking u

[3369 byte] By [2569a] at [2007-11-27 6:01:36]
# 1
repost the code using the [ code ] formatting tag so it is at least possible to read it. Check the "code" button above the input field when making a post.
gimbal2a at 2007-7-12 16:41:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Hi, I have developed a JSP, having two split fields seperated by some buttons..The sample code for the same is like this..

(Only the required portion is included)

<script>

function reloadPageOK() {

document.product.method="post"

document.product.action="./TheSamePage.jsp?status=OK"

document.product.submit()

}

function moveValue(from,to) {

if(from.selectedIndex>=0) {

var text=from[from.selectedIndex].text

var length= to.length

to[length]=new Option(text,from.value,false,false)

from.remove(from.selectedIndex)

}

}

function moveAll(from,to) {

if(from.length>0) {

var menutext="";

var i;

var len=from.length

for(i=0;i<len;i++) {

from.selectedIndex=0

menutext=from[0].text

var length= to.length

to[length]=new Option(menutext,from.value,false,false)

from.remove(from.selectedIndex)

}

}

}

></script>

<table width="100%" border="0" cellspacing="0" >

<tr class="contactDetail">

<td width="10%" class="table_grid1" rowspan="4">

<div class="contactDetail">

<select name="lstProviderLeft" size="7" style="width:111">

<option> PDP</option>

<option> Net</option>

<option> Par</option>

<option> Non-Par</option>

</select>

</div>

</td>

<td width="20%" bgcolor="#FFFFFF" class="contactDetail">

<input type="button" value="&gt;" name="btnLtrProvider" class="button" onclick="moveValue(lstProviderLeft,lstProviderRight)">

</td>

<td width="10%" bgcolor="#FFFFFF" rowspan="4" class="contactDetail"> <font face="Arial, Verdana, Helvetica, sans-serif" size="2" >

<select name="lstProviderRight" size="7" style="width:111"></select>

</font></td>

<tr>

<td width="8%" class="contactDetail">

<input type="button" value=" &gt;&gt; " name="btnLtrAllProvider" class="button" onclick="moveAll(lstProviderLeft,lstProviderRight)" >

</td>

</tr>

<tr>

<td width="8%" class="contactDetail">

<input type="button" name="btnRtlProvider" value="&lt;" class="button" onclick="moveValue(lstProviderRight,lstProviderLeft)" >

</td>

</tr>

<tr>

<td width="8%" class="contactDetail" height="22">

<input type="button" name="btnRtlAllProvider" value=" &lt;&lt; " class="button" onclick="moveAll(lstProviderRight,lstProviderLeft)" >

</td>

</tr>

</table>

<p align = "center"> <input type="button" value="OK" onclick="reloadPageOK()">

The page is working fine. That is we can move the values in the left field to right as single or group.After submitting I need to get the values in the left & right fields respectively. I have used the method

request.getParameterValues("lstProviderLeft");

and pointed this to an array of strings,but it returns 'null' . How can I solve the above problem....Post your comments on this issue

Thanking u

2569a at 2007-7-12 16:41:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
I have reposted the code please check.
2569a at 2007-7-12 16:41:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

probably the request.getParmeterValues will not work in this case as the name of the 2 select boxes are different....

You can do this utility by using Javascript....concantinate the values of the 2 select boxes and put the concantinated strings (with a delimiter) in two hidden fields and capture the same fields in the target JSP/Servlet.

I have modified ur code...have a look...

--Start--

<html>

<head></head>

<title></title>

<body>

<script language="Javascript">

function reloadPageOK()

{

document.product.method="post" ;

document.product.action="./TheSamePage.jsp?status=OK" ;

document.product.submit();

}

function moveValue(from,to)

{

if(from.selectedIndex>=0)

{

var text=from[from.selectedIndex].text;

var length= to.length ;

to[length]=new Option(text,from.value,false,false);

from.remove(from.selectedIndex);

}

}

function moveAll(from,to)

{

if(from.length>0)

{

var menutext="";

var i;

var len=from.length;

for(i=0;i<len;i++)

{

from.selectedIndex=0;

menutext=from[0].text ;

var length= to.length;

to[length]=new Option(menutext,from.value,false,false) ;

from.remove(from.selectedIndex);

}

}

}

function fnSubmitPage(from,to)

{

var strfromSelBox = "";

var strtoSelBox = "";

if(from.length>0)

{

var len=from.length;

for(var i=0;i<len;i++)

{

strfromSelBox=strfromSelBox+":"+from[i].text ;

}

}

if(to.length>0)

{

var len=to.length;

for(var i=0;i<len;i++)

{

strtoSelBox=strfromSelBox+":"+to[i].text ;

}

}

document.product.hdFromValue.value=strfromSelBox;

document.product.hdFromValue.value=strtoSelBox;

document.product.method="post" ;

document.product.action="" ;//Name of the JSP or servlet wherever u want to direct to....

document.product.submit();

}

></script>

<form name="product">

<input type="hidden" name="hdFromValue">

<input type="hidden" name="hdToValue">

<table width="100%" border="0" cellspacing="0" >

<tr class="contactDetail">

<td width="10%" class="table_grid1" rowspan="4">

<div class="contactDetail">

<select name="lstProviderLeft" size="7" style="width:111">

<option> PDP</option>

<option> Net</option>

<option> Par</option>

<option> Non-Par</option>

</select>

</div>

</td>

<td width="20%" bgcolor="#FFFFFF" class="contactDetail">

<input type="button" value=" &gt; " name="btnLtrProvider" class="button" onclick="moveValue(lstProviderLeft,lstProviderRight)">

</td>

<td width="10%" bgcolor="#FFFFFF" rowspan="4" class="contactDetail">

<font face="Arial, Verdana, Helvetica, sans-serif" size="2" >

<select name="lstProviderRight" size="7" style="width:111">

</select>

</font>

</td>

<tr>

<td width="8%" class="contactDetail">

<input type="button" value=" &gt;&gt; " name="btnLtrAllProvider" class="button" onclick="moveAll(lstProviderLeft,lstProviderRight)" >

</td>

</tr>

<tr>

<td width="8%" class="contactDetail">

<input type="button" name="btnRtlProvider" value=" &lt; " class="button" onclick="moveValue(lstProviderRight,lstProviderLeft)" >

</td>

</tr>

<tr>

<td width="8%" class="contactDetail" height="22">

<input type="button" name="btnRtlAllProvider" value=" &lt;&lt; " class="button" onclick="moveAll(lstProviderRight,lstProviderLeft)" >

</td>

</tr>

</table>

<input type="button" value=" OK " onclick="reloadPageOK()">

<input type="button" value=" Submit " onclick="fnSubmitPage(lstProviderRight,lstProviderLeft)">

</form>

</body>

</html>

--Finish

Hope this helps...

Thanks

anurag_dasha at 2007-7-12 16:41:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
Thanks for your response. But its not working with my code. What should i do ,If two split select fields are there ?Expect your comments Thanking you,Kris
2569a at 2007-7-12 16:41:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
the select will add only values that are selected to the form submit. So before the submit, set all the options in your selectbox to selected and it should work.
gimbal2a at 2007-7-12 16:41:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7
Thanks a ton its working fine.............
2569a at 2007-7-12 16:41:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...