MDanz Posted January 11, 2010 Share Posted January 11, 2010 this doesn't work. i want the form action to go the location.href of the submit button chosen.. how do i do this? <?php echo "<form enctype='multipart/form-data' action='location.href' method='post' name='changer'> <table width='376' height='76' border='0'> <tr> <td> <font color=white font face=Verdana>Subject: </font><input type='text' name='keywords' value=''> </td> </tr> <tr> <td align='center'><input type='submit' name='Add Webpage' id='Add Webpage' value='Add Webpage' onClick='location.href=\"stacker.php\"'></td> <td align='center'><input type='submit' name='Add Topice' id='Add Topic' value='Add Topic' onClick='location.href=\"uinfo.php\"'></td> <td align='center'><input type='submit' name='Add Image' id='Add Image' value='Add Image' onClick='location.href=\"uimage.php\"'></td> </tr> </table></form>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/188000-form-help/ Share on other sites More sharing options...
jeremy0 Posted January 11, 2010 Share Posted January 11, 2010 you see where it says action='location.href' will the form work? meaning will it send the value "keyword" to the submit button(page) chosen? <?php echo "<form enctype='multipart/form-data' action='location.href' method='post' name='changer'> <table width='376' height='76' border='0'> <tr> <td> <font color=white font face=Verdana>Subject: </font><input type='text' name='keywords' value=''> </td> </tr> <tr> <td align='center'><input type='submit' name='Add Webpage' id='Add Webpage' value='Add Webpage' onClick='location.href=\"stacker.php\"'></td> <td align='center'><input type='submit' name='Add Topice' id='Add Topic' value='Add Topic' onClick='location.href=\"uinfo.php\"'></td> <td align='center'><input type='submit' name='Add Image' id='Add Image' value='Add Image' onClick='location.href=\"uimage.php\"'></td> </tr> </table></form>"; ?> sorry - to get the input token 'keyword' sent, you need to either use separate forms for each submit button, or remove the form tag and hidden field entirely, and encode a get url for each button... Quote Link to comment https://forums.phpfreaks.com/topic/188000-form-help/#findComment-992524 Share on other sites More sharing options...
tail Posted January 11, 2010 Share Posted January 11, 2010 --posted too late-- Quote Link to comment https://forums.phpfreaks.com/topic/188000-form-help/#findComment-992525 Share on other sites More sharing options...
MDanz Posted January 11, 2010 Author Share Posted January 11, 2010 ok.. i changed it to 3 seperate forms.. how do i post the keywords for whatever form chosen, without displaying 3 input boxes for keywords. i'm thinking 4 input text fields(3 invisible) and typing in the first input text field types in the invisible textfields? so the question now is how do i input into multiple input text fields at the same time? <?php echo " <table width='600' height='76' border='0'> <tr> <td align='center' colspan='3'> <font color=white face=Arial color=#FBB917><strong>Subject: </strong></font><input type='text' name='keywords' value=''> </td> </tr> <tr> <td align='center'> <form enctype='multipart/form-data' action='stacker.php' method='post' name='changer'><input type='submit' name='Add Webpage' id='Add Webpage' value='Add Webpage' ></form></td> <td align='center'> <form enctype='multipart/form-data' action='uinfo.php' method='post' name='changer'><input type='submit' name='Add Topice' id='Add Topic' value='Add Topic' ></form></td> <td align='center'> <form enctype='multipart/form-data' action='uimage.php' method='post' name='changer'><input type='submit' name='Add Image' id='Add Image' value='Add Image' ></form></td> </tr> </table>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/188000-form-help/#findComment-992527 Share on other sites More sharing options...
jeremy0 Posted January 11, 2010 Share Posted January 11, 2010 use javascript - <script type="text/javascript"> function setForms(data) { document.form1.keywords.value = data; document.form2.keywords.value = data; .... } </script> <form name="form1"...> <input type="hidden" name="keywords" value=""/> <input type="submit"...> </form> <form name="form2"...> <input type="hidden" name="keywords" value=""/> <input type="submit"..> </form> ... (other forms) (actual keywords entry box) <input type="text" name="keywords_entry" value="" onchange="setForms(this.value);"> Quote Link to comment https://forums.phpfreaks.com/topic/188000-form-help/#findComment-992530 Share on other sites More sharing options...
MDanz Posted January 11, 2010 Author Share Posted January 11, 2010 thankyou. i'll try this Quote Link to comment https://forums.phpfreaks.com/topic/188000-form-help/#findComment-992536 Share on other sites More sharing options...
MDanz Posted January 11, 2010 Author Share Posted January 11, 2010 i tried doesn't work though.. i made the boxes visible to test, they don't fill up? problem with javascript? <script type="text/javascript"> function setForms(data) { document.changer1.keywords.value = data; document.changer2.keywords.value = data; document.changer3.keywords.value = data; } </script> <?php echo " <table width='600' height='76' border='0'> <tr> <td align='center'> <form enctype='multipart/form-data' action='stacker.php' method='post' name='changer1'><input type='text' name='keywords' value=''><input type='submit' name='Add Webpage' id='Add Webpage' value='Add Webpage' ></form></td> <td align='center'> <form enctype='multipart/form-data' action='uinfo.php' method='post' name='changer2'><input type='text' name='keywords' value=''><input type='submit' name='Add Topice' id='Add Topic' value='Add Topic' ></form></td> <td align='center'> <form enctype='multipart/form-data' action='uimage.php' method='post' name='changer3'><input type='text' name='keywords' value=''><input type='submit' name='Add Image' id='Add Image' value='Add Image' ></form></td> </tr> <tr> <td align='center' colspan='3'> <font color=white face=Arial color=#FBB917><strong>Subject: </strong></font><input type='text' name='keywords_entry' value='' onchange='setForms(this.value);'> </td> </tr> </table>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/188000-form-help/#findComment-992570 Share on other sites More sharing options...
MDanz Posted January 11, 2010 Author Share Posted January 11, 2010 actually it does work but i have to click on the text fields for them to appear... how do i do this when they are hidden? Quote Link to comment https://forums.phpfreaks.com/topic/188000-form-help/#findComment-992574 Share on other sites More sharing options...
jeremy0 Posted January 11, 2010 Share Posted January 11, 2010 i tried doesn't work though.. i made the boxes visible to test, they don't fill up? problem with javascript? <script type="text/javascript"> function setForms(data) { document.changer1.keywords.value = data; document.changer2.keywords.value = data; document.changer3.keywords.value = data; } </script> <?php echo " <table width='600' height='76' border='0'> <tr> <td align='center'> <form enctype='multipart/form-data' action='stacker.php' method='post' name='changer1'><input type='hidden' name='keywords' value=''><input type='submit' name='Add Webpage' id='Add Webpage' value='Add Webpage' ></form></td> <td align='center'> <form enctype='multipart/form-data' action='uinfo.php' method='post' name='changer2'><input type='hidden' name='keywords' value=''><input type='submit' name='Add Topice' id='Add Topic' value='Add Topic' ></form></td> <td align='center'> <form enctype='multipart/form-data' action='uimage.php' method='post' name='changer3'><input type='hidden' name='keywords' value=''><input type='submit' name='Add Image' id='Add Image' value='Add Image' ></form></td> </tr> <tr> <td align='center' colspan='3'> <font color=white face=Arial color=#FBB917><strong>Subject: </strong></font><input type='text' name='keywords_entry' value='' onchange='setForms(this.value);'> </td> </tr> </table>"; ?> Hide the input controls for the form. Please remember that the onchange event on the visible text field doesn't fire until that text field loses focus. I.e. when the user types something in, and hits one of the submit buttons, the 'keywords' value for all submit buttons are changed to the text field's value, and then the submit button that is clicked on submits its form. Quote Link to comment https://forums.phpfreaks.com/topic/188000-form-help/#findComment-992578 Share on other sites More sharing options...
teamatomic Posted January 11, 2010 Share Posted January 11, 2010 Jumping in a bit late but I think you are overly complicating the thing. Why not have one form with the keywords input and a select/option box with what you want in the submits. Then your action goes to a controller page that redirects to the various php pages. HTH Teamatomic Quote Link to comment https://forums.phpfreaks.com/topic/188000-form-help/#findComment-992585 Share on other sites More sharing options...
jeremy0 Posted January 11, 2010 Share Posted January 11, 2010 teamatomic: i must be fried tonight - that is a simpler way.. Quote Link to comment https://forums.phpfreaks.com/topic/188000-form-help/#findComment-992590 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.