rgb192
asked on
dropdown menu without submit button
want to update page when user
uses dropdown menu
do not want submit button
can not change this line
<form id="xyz">
<form id="xyz">
<select>
<option>Paint</option>
<option>Brushes</option>
<option>Erasers</option>
</select>
</form>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Remove the backslashes around form?
<html>
<form id="xyz">
<select onchange="alert(this.optio ns[this.se lectedInde x].value); " >
<option>Paint</option>
<option>Brushes</option>
<option>Erasers</option>
</select>
</form>
</html>
<form id="xyz">
<select onchange="alert(this.optio
<option>Paint</option>
<option>Brushes</option>
<option>Erasers</option>
</select>
</form>
</html>
Then if you want to pass it to the function:
<html>
<script type="text/javascript">
function selectfunction(mystring)
{
alert(mystring + ' was selected');
}
</script>
<form id="xyz">
<select onchange="selectfunction(t his.option s[this.sel ectedIndex ].value);" >
<option>Paint</option>
<option>Brushes</option>
<option>Erasers</option>
</select>
</form>
</html>
<html>
<script type="text/javascript">
function selectfunction(mystring)
{
alert(mystring + ' was selected');
}
</script>
<form id="xyz">
<select onchange="selectfunction(t
<option>Paint</option>
<option>Brushes</option>
<option>Erasers</option>
</select>
</form>
</html>
If you want to generate source using PHP you have to make a server request of some sort-- either a simple page either reloading the current or a new page or loading a page in an IFRAME. Try looking at AJAX --here' is link:http://www.dynamicdrive.com/dynamicindex16/chainedselects/index.htm
you need to add a onload event handler to make sure your element exists before trying to work with it, so this code should be able to be placed anywhere
<script type="text/javascript">
window.onload=function(){
document.getElementById('xyz').getElementsByTagName('select').onChange = "document.getElementById('xyz').submit()";
}
</script>
ASKER
<select onchange="alert(this.optio ns[this.se lectedInde x].value); " >
produced an alert text box
all of these did nothing
<script type="text/javascript">
is there a way to make the page refresh when dropdown select
produced an alert text box
all of these did nothing
<script type="text/javascript">
is there a way to make the page refresh when dropdown select
This will:
<select onChange="document.getElem entsByTagN ame('form' )(0).submi t()">
You just have to make sure you don't paste it twice again. And make sure it doesn't have backslashes in it.
<select onChange="document.getElem
You just have to make sure you don't paste it twice again. And make sure it doesn't have backslashes in it.
ASKER
<select onChange="document.getElem entsByTagN ame('form' )(0).submi t()">
this does not refresh the page
but your alert box worked
this does not refresh the page
but your alert box worked
Yeah... I am stupid... square brackets:
<select onChange="document.getElem entsByTagN ame('form' )[0].submi t()">
<select onChange="document.getElem
ASKER
<select onChange="document.getElem entsByTagN ame('form' )[0].submi t()">
refreshes page
to
index.php?a=updatecart&ci[ 15044]=1
could i refresh page to
index.php
refreshes page
to
index.php?a=updatecart&ci[
could i refresh page to
index.php
<select onChange="document.getElem entsByTagN ame('form' )[0].metho d="post";d ocument.ge tElementsB yTagName(' form')[0]. submit()">
ASKER
now page does not refresh
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Besides the fact that Ray's comment is absolutley correct, this might be a solution.
Put the script into the page.
<script type="text/javascript">
</--
function sendForm() {
document.getElementsByTagN ame('form' )[0].metho d="post";
document.getElementsByTagN ame('form' )[0].submi t()
}
//-->
</script>
Then change the select to this line:
<select onChange="sendForm();">
Put the script into the page.
<script type="text/javascript">
</--
function sendForm() {
document.getElementsByTagN
document.getElementsByTagN
}
//-->
</script>
Then change the select to this line:
<select onChange="sendForm();">
ASKER
didnt refresh the page
ASKER
thanks
ASKER
dont understand
1st comment
2nd comment
document.getElementById('x
can i put this on the line before 'form'
because I cant change the <header></header> without editing many pages
3rd comment
my code submits to same page and do nto want to change this
4th comment
<select onChange="document.getElem
did not refresh page