davidw88
asked on
How to find this value
Hi experts,
On a webpage there is a drop-down menu that has page numbers like 2, 3, 4. When a user chooses a number, the webpage is supposed to change to that page. However, the script that I have now does not work.
Any help?
Thanks so much.
On a webpage there is a drop-down menu that has page numbers like 2, 3, 4. When a user chooses a number, the webpage is supposed to change to that page. However, the script that I have now does not work.
Any help?
Thanks so much.
function submitPage(){
var box = document.accountreport.pageBox;
var pgNo = box.options[box.selectedIndex].value;
document.location.href = "auth_token.htm?pgNo="+ pgNo;
}
//-----------------------------------------
related part of jsp:
<form name="accountreport">
<select id="pageBox" name="pageBox" onChange="javascript:submitPage();">
<c:forEach items="${pages}" var="page" varStatus="loop">
<option value="<c:out value="${page}"/>"
<c:if test="${page == param.pgNo}">SELECTED</c:if>><c:out value="${page}" />
</option>
</c:forEach>
</select>
</form>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks hielo! Your solution works perfect.
I have figured out why my old script did not work. It should be something like this:
var boxObj = document.getElementById('p ageBox');
var pgNo = boxObj.options[boxObj.sele ctedIndex] .value;
this works.
I have figured out why my old script did not work. It should be something like this:
var boxObj = document.getElementById('p
var pgNo = boxObj.options[boxObj.sele
this works.
ASKER
I added "pgNo=" when I tested your script :)
Should have been:
if( box.selectedIndex > -1 )
pgNo=box.options[box.selec tedIndex]. value;
Should have been:
if( box.selectedIndex > -1 )
pgNo=box.options[box.selec
>> box.options[box.selectedIn
Should have been:
if( box.selectedIndex > -1 )
pgNo=box.options[box.selectedIn