Darkmatter5 Posted June 15, 2009 Share Posted June 15, 2009 Here's my js <script type="text/javascript" src="<?php echo "$url/library/scripts/selectclass.js"; ?>" /></script> <script type="text/javascript" /> function subit(which) { if(which=='reroll') { document.attributes.action="res_t-pcb2.php?roll=yes"; } else if(which=='attributes') { document.attributes.action="tools/scripts/pcb.php"; } } </script> Here's my html <form method="get" name="attributes"> <input type="hidden" name="page" value="2"> <table> <tr> <td align="right"><label for="abil_str">Str: </label></td> <td><input type="text" name="abil_str" size="2" value="<?php if($_GET['roll']=='yes') { $werbgame->roll_dice(4,6,0,1); } ?>"> <?php echo substr($werb->getdata("descr","SELECT descr FROM d_abilities WHERE ability='strength'"),0,50); ?></td> </tr> <tr> <td align="right"><label for="abil_dex">Dex: </label></td> <td><input type="text" name="abil_dex" size="2" value="<?php if($_GET['roll']=='yes') { $werbgame->roll_dice(4,6,0,1); } ?>"> <?php echo substr($werb->getdata("descr","SELECT descr FROM d_abilities WHERE ability='dexterity'"),0,50); ?></td> </tr> <tr> <td align="right"><label for="abil_dex">Con: </label></td> <td><input type="text" name="abil_con" size="2" value="<?php if($_GET['roll']=='yes') { $werbgame->roll_dice(4,6,0,1); } ?>"> <?php echo substr($werb->getdata("descr","SELECT descr FROM d_abilities WHERE ability='constitution'"),0,50); ?></td> </tr> <tr> <td align="right"><label for="abil_dex">Int: </label></td> <td><input type="text" name="abil_int" size="2" value="<?php if($_GET['roll']=='yes') { $werbgame->roll_dice(4,6,0,1); } ?>"> <?php echo substr($werb->getdata("descr","SELECT descr FROM d_abilities WHERE ability='intelligence'"),0,50); ?></td> </tr> <tr> <td align="right"><label for="abil_dex">Wis: </label></td> <td><input type="text" name="abil_wis" size="2" value="<?php if($_GET['roll']=='yes') { $werbgame->roll_dice(4,6,0,1); } ?>"> <?php echo substr($werb->getdata("descr","SELECT descr FROM d_abilities WHERE ability='wisdom'"),0,50); ?></td> </tr> <tr> <td align="right"><label for="abil_dex">Cha: </label></td> <td><input type="text" name="abil_cha" size="2" value="<?php if($_GET['roll']=='yes') { $werbgame->roll_dice(4,6,0,1); } ?>"> <?php echo substr($werb->getdata("descr","SELECT descr FROM d_abilities WHERE ability='charisma'"),0,50); ?></td> </tr> <tr><td colspan="2" align="center"><input type="submit" name="reroll" value="Reroll" onclick="javascript:subit(reroll);"> <input type="submit" name="submit" value="Submit" onclick="javascript:subit(attributes);"></td></tr> </table> </form> When either submit button is pressed the following is sent to the browser. "res_t-pcb_p2.php?page=2&abil_str=&abil_dex=&abil_con=&abil_int=&abil_wis=&abil_cha=&reroll=Reroll" "res_t-pcb_p2.php?page=2&abil_str=&abil_dex=&abil_con=&abil_int=&abil_wis=&abil_cha=&submit=Submit" If reroll is pressed it should set the form action to "res_t-pcb2.php?roll=yes". If submit is pressed it should set the form action to "tools/scripts/pcb.php". What's wrong? Link to comment https://forums.phpfreaks.com/topic/162255-form-with-dynamic-action/ Share on other sites More sharing options...
rhodesa Posted June 15, 2009 Share Posted June 15, 2009 first thing i notice is you need some quotes around reroll and attributes: onclick="javascript:subit('reroll');" Link to comment https://forums.phpfreaks.com/topic/162255-form-with-dynamic-action/#findComment-856348 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.