|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
onClick and Pull Down Boxes
Form works with select button,
doesn't work onClick. JS is enabled on page. Newbie PHP but getting better. No JS background. Code is as follows: <table border = "2" class='form'> <tr> <th>Business Categories</th> </tr> <tr> <td> <form name="Trianglecategories" method = "post"/> <input type="hidden" name="category" value="category" onclick="document.Trianglecategories.setAttribute('action', 'Categoryindex.php')"/> This remark not in code---the require below Contains all Options---- <?php require("Trianglecategories.php")?> <input class="submit" type="submit" name="submit" value="GO" onclick="document.Trianglecategories.setAttribute('action', 'Categoryindex.php')" > </form> </td> </tr> </table> Question: Is document a reserved JS word or should this be the path to Trianglecategories ps. put onclick in both places in desperation! Any help is appreciated |
|
#2
|
|||
|
|||
|
Message Moved
Thread moved from 'PHP Coding' to 'Client Side Things' by nawlej.
Reason: javascript related. |
|
#3
|
|||
|
|||
|
RE: onClick and Pull Down Boxes
what is it that you want to happen? it is not clear what you are trying to do. Also, onclick in the hidden field is not needed. Let me know what you want to do and I will see if I can help.
|
|
#4
|
|||
|
|||
|
RE: onClick and Pull Down Boxes
Want each of the options in the pull down to take action on either a click within the box or by clicking on the sumbit button "GO"
|
|
#5
|
|||
|
|||
|
RE: onClick and Pull Down Boxes
in dropdowns, use the onchange event, not the onclick. you will also need to include the submit() method for this to work. Post the code for the dropdowns and I will put together an example.
|
|
#6
|
|||
|
|||
|
RE: onClick and Pull Down Boxes
Not sure which pull down code you are looking for besides what I aready posted but here is a subset of the reqire code
<!-- START of Trianglecategories.php --> <?php $category = 'Select'?> <select name='category'> <option value="<?php echo $Category;?>" SELECTED><?php echo $category;?></option> <!-- add, remove or change any of the select option items below. --> <option value="Grand Openings">Grand Openings</option> <option value="Shopping Destinations">Shopping Destinations</option> </SELECT> <!-- END of categoriesINDUSTRY.php --> |
|
#7
|
|||
|
|||
|
RE: onClick and Pull Down Boxes
here is what you do... change the select tag like so...one thing I should mention first, is that you have two form elements with the same name (the hidden field and the select...not sure what the hidden field is for)which will cause problems.
<select name='category' onchange="document.Trianglecategories.setAttribute('action', 'Categoryindex.php');document.Trianglecategories.s ubmit();" > That will submit the form each time a new selection is chosen. Another thing, is the action attribute of the form going to be different for the dropdown and the submit button? If not, I would just hard code the action attribute in the form tag and remove the setattribute commands as it would be overkill. |
|
#8
|
|||
|
|||
|
RE: onClick and Pull Down Boxes
Got it... I'm grab a bite to eat first,change the code and test it out, and get back to you ...much appreciated!
|
|
#9
|
|||
|
|||
|
RE: onClick and Pull Down Boxes
No change in form behavior
Form works by using the submit "go" button but does not take "action" on selecting anythig within the pull down box I must still be doing something wrong. I Changed the code to: <td> <form name="Trianglecategories" method = "post"/> <?php require("Trianglecategories.php")?> <input class="submit" type="submit" name="submit" value="GO"> </form> </td> <!-- START of Trianglecategories.php --> <?php $category = 'Select'?> <select name='category' onchange="document.Trianglecategories.setAttribute('action', 'Categoryindex.php');document.Trianglecategories.s ubmit();" > <option value="<?php echo $Category;?>" SELECTED><?php echo $category;?></option> <!-- This MUST be line 20: Add, remove or change any of the select option items below. --> <option value="Grand Openings">Grand Openings</option> <option value="Shopping Destinations">Shopping Destinations</option> </SELECT> <!-- END of categoriesINDUSTRY.php --> |
|
#10
|
|||
|
|||
|
RE: onClick and Pull Down Boxes
lets simplify it a little first hard code the form action and change the name of the submit button to catsubmit (nameing it submit interferes with the submit() method sorry but I missed that before)
<form name="Trianglecategories" method = "post" action="Categoryindex.php"/> <?php require("Trianglecategories.php")?> <input class="submit" type="submit" name="catsubmit" value="GO"> </form> then in the trianglecategories.php use this code <?php $category = 'Select'?> <select name="category" onChange="document.Trianglecategories.submit();" > <option value="<?php echo $Category;?>" SELECTED><?php echo $category;?></option> <option value="Grand Openings">Grand Openings</option> <option value="Shopping Destinations">Shopping Destinations</option> </SELECT> that should do it |
|
#11
|
|||
|
|||
|
RE: onClick and Pull Down Boxes
Works like a charm! Thanks Muchly!
Is there an online JS Manual similar to PHP? At this site? ps Sliced Bread is not my favorite, I like French and Italian, the kind you slice yourself! But presliced is convenient! Thanks again |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Client Side Things > onClick and Pull Down Boxes |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|