javascript - menu change page information -
i'm trying have multiple dropbox menu's on same page change information on next page after submitting selection.
so user can make different , multipule selections menus click "submit" , different information on next page , not same page script below.
this closest thing ive found trying information on next page instead proving tricky.
<form> <table> <tr> <td>person 1</td> <td>information</td> <td> <select id="choice1" onchange="changetext('choice1', 'display1')"> <option>select</option> <optgroup label="category 1"> <option>g1 choice1</option> <option>g1 choice2</option> </optgroup> <optgroup label="category 2"> <option>g2 choice1</option> <option>g2 choice2</option> </optgroup> </select> </td> </tr> <tr> <td>person 2</td> <td>information</td> <td> <select id="choice2" onchange="changetext('choice2', 'display2')"> <option>select</option> <optgroup label="category 1"> <option>g1 choice1</option> <option>g1 choice2</option> </optgroup> <optgroup label="category 2"> <option>g2 choice1</option> <option>g2 choice2</option> </optgroup> </select> </td> </tr> </table> <p> </p> <table> <tr> <td><div id="display1">select option</div></td> </tr> <tr> <td><div id="display2">select option</div></td> </tr> </table> <p> </p> </form> <script> var textblocks = [ 'select option', 'g1 choice1 description', 'g1 choice2 description', 'g2 choice1 description', 'g2 choice2 description' ]; function changetext(elemid, displayid) { var ind = document.getelementbyid(elemid).selectedindex; document.getelementbyid(displayid).innerhtml = textblocks[ind]; } </script> </body> </html>
post data sent server , not returned client. means javascript code never see submitted.
you either need whatever want server-sided (i.e., in php) or need change way send , read data (i.e., via hash part of url, via cookies,...). using server-side language better option, although depend on trying achieve.
Comments
Post a Comment