How do I take values entered on one html page's form, and enter them on another html page as variables

60 views Asked by At

I have this form on an options page for a website I am working on:

<form method="POST" action="process.asp" name="form1"> 
    <table width="70%" border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td>Number of slides:</td>
            <td colspan="2"><input type="text" name="numberOf"></td>
        </tr>
        <tr>
            <td>Seconds between slides:</td>
            <td colspan="2"><input type="text" name="secondsBetween"></td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td colspan="2"><input type="submit" name="submit" value="Submit"></td>
        </tr>
    </table>
</form>

I need the values entered inside of the input fields to be used as the variables in a separate pages javascript as shown here:

var betweenDivs = (10 * 1000),
    numSlides = 0;

I can't figure out any way to do this. It needs to work on an ISS server.

3

There are 3 answers

0
RightClick On BEST ANSWER

In process.asp, you can print out the variable from the form, right into your javascript.

<script>
var betweenDivs = (<% response.write(request.form("secondsBetween")) %> * 1000),
    numSlides = <% response.write(request.form("numberOf")) %>;
</script>
0
Fabio Pellerito On
var betweenDivs = (<%= request.form("secondsBetween")%> * 1000),
    numSlides = <%= request.form("numberOf")%>;
0
hooda On

A rudimentary way to accomplish this would be to have the posted values from the one page be stored in hidden input fields on the next page like so <input type="hidden" value="(value from the request)">. Then you could use javascript to read the values from the input fields.

Alternatively you could fire an ajax request on the second page that has the posted values returned from the server as a JSON object.