Link to home
Start Free TrialLog in
Avatar of tmurray22
tmurray22

asked on

Javascript change element to pick up request.form value

I have a form that was on one page and working fine. I split it up to two pages(for visual puposes)
but now my javascript doesnt work.

The codeline is now on form1

and this script is on form2

How do I change to reference the codeline value from form 2 ?

function checkValues(frm)
{
if ((frm.elements["codeline"].options[frm.elements["codeline"].selectedIndex].text=="5.0")) frm.action="Testpost2.asp";
else frm.action="testpost.asp";
return true;
}
</script>

Avatar of Zvonko
Zvonko
Flag of North Macedonia image

When form1 is submitted to server then you responde with the form2 page, right?
Then you can responde also the selected value into form2 page.
Like this:


function checkValues(frm){
if ((<% =Request.Form("codeline") %>=="5.0")) frm.action="Testpost2.asp";
else frm.action="testpost.asp";
return true;
}
</script>

But you should not do such simple scripts in JavaScript.
Better do it in ASP script and adapt the <form action= appropriate.

Avatar of tmurray22
tmurray22

ASKER

yes. that works, but when I change the value like below it gives me the testpost2.asp everytime

<script>
function checkValues(frm){
if ((<% =Request.Form("cmpsub") %>=="dm3ssp")) frm.action="adfield.asp";
else frm.action="testpost.asp";
return true;
}
</script>
Show both forms in HTML and ASP then I can analyze what you are doing.
ASKER CERTIFIED SOLUTION
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That did it, Thanks
You are welcome