on drop down selection - El Forum - 11-29-2010
[eluser]diasansley[/eluser]
below is my view code i wanted to add a script that directly takes the select value when u select an option from the drop down without using the submit button.
Code: <li class="brands_dropdown">
<h4 class="h4">Marken</h4>
<?= form_open('entries/showAllEntries');?>
<select name="brands" id="brands" class="lisbox">
<option value="0">--Select--</option>
<?php
foreach($brands as $brand):
if(isset($type) && $type == 'brand')
$selected = ($brand['id']==$type_id)? 'selected = "selected"' : '';
else
$selected='';
?>
<option value="<?=$brand['id'];?>" <?=$selected;?>><?=$brand['name']?></option>
<?php endforeach;?>
</select>
<input type="hidden" value="brand" id="entry_type0" name="entry_type" />
<input type="submit" value="Submit" />
<?=anchor('brands/showAllBrands', 'alle Marken', array('id'=>'all_brands_link'));?>
<?= form_close();?>
</li>
thanks rgds
on drop down selection - El Forum - 11-29-2010
[eluser]LuckyFella73[/eluser]
Code: <scr+ipt type="text/javascript">
function dropdown_submit(form)
{
var index=form.select.selectedIndex
if (form.select.options[index].value != "0")
{
// document.forms["myform"].submit(); // edit for your needs!
}
}
</scr+ipt>
Code: <select name="select" on+change="dropdown_submit(this.form)" size="1"> // remove '+' of course
on drop down selection - El Forum - 11-29-2010
[eluser]diasansley[/eluser]
i have added a [removed] but the function keyword is not getting highlighted in Pseditor.. any ideas. and also no action is performed. even after including the script.
Thanks Rgds
on drop down selection - El Forum - 11-29-2010
[eluser]LuckyFella73[/eluser]
Hard to say whats going wrong without seeing your code.
Please post js part and HTML part with your select element.
on drop down selection - El Forum - 11-29-2010
[eluser]diasansley[/eluser]
there is no action taking place.and also hoe do i send the data for processing in absence of a submit button.
Code: <select name="entries" id="entries" class="lisbox">
< script type="text/javascript">
function subsubmit(form)
{
var index=form.select.selectedIndex
if (form.select.options[index].value != "0")
{
}
}
[removed]
<option value="0">--Select-- </option>
<?php foreach($entries as $entry):?>
<option value="<?=$entry['id'];?>"><?= $entry['name']?></option>
<?php endforeach;?>
</select>
<noscript>
<input type="submit" value="Submit" />
</noscript>
<?=anchor('entries/showAllEntries', 'alle Mieter', array('id' => 'all_entries_link'));?>
<?= form_close();?>
</li>
on drop down selection - El Forum - 11-29-2010
[eluser]diasansley[/eluser]
ok i have made the foll changes included a js file but still no action is performed.
I have included my script at the end.
Code: <li class="entry_dropdown">
<h4 class="h4">Mieter</h4>
<?= form_open('entries/showEntryDetail');?>
<select name="entries" id="entries" class="lisbox">
<option value="0">--Select-- </option>
< script type="text/javascript" src="C:\xampp\htdocs\front_end\load.js" >
<?php foreach($entries as $entry):?>
<option value="<?=$entry['id'];?>"><?= $entry['name']?></option>
<?php endforeach;?>
</select>
<noscript>
<input type="submit" value="Submit" />
</noscript>
<?=anchor('entries/showAllEntries', 'alle Mieter', array('id' => 'all_entries_link'));?>
<?= form_close();?>
</li>
Code: < script type="text/javascript">
function dropdown_submit(form)
{
var index=form.select.selectedIndex
if (form.select.options[index].value != "0")
{
<?=anchor('entries/showAllEntries',array('id' => 'all_entries_link'));?>
}
}
< /script>
on drop down selection - El Forum - 11-29-2010
[eluser]LuckyFella73[/eluser]
I set up a complete example - you just have to adjust some code:
Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
<title>Form</title>
<scr++ipt type="text/javascript">
function sub_submit(data)
{
if (data != "0")
{
document.forms["myform"].submit();
}
}
</scr++ipt>
</head>
<body>
<h4 class="h4">Marken</h4>
<form id="myform" name="myform" action="showsubmitted.php" method="post">
<select name="brands" id="brands" on++change="sub_submit(this.options[this.selectedIndex].value)">
<option value="0">--Select--</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<input type="hidden" value="brand" id="entry_type0" name="entry_type" />
<input type="submit" value="Submit" />
</form>
</body>
</html>
Just replace the "++", the form open and tag your select loop block.
I didn't want to set up controller to test so I did a pure html version.
on drop down selection - El Forum - 11-29-2010
[eluser]diasansley[/eluser]
ok thanks a lot... it helped.
|