Welcome Guest, Not a member yet? Register   Sign In
pass value with onchange event of a combo box
#1

[eluser]ranjitbd[/eluser]
Code:
// this part is inside model
select p.id, p.package_name, d.duration from hld_package p, hld_duration d
where p.duration_id = d.id
// it generates few lines from data base and return the array of values to the
// controller and go back to the following view page

// view page 'itinerary_add.php'


// $itinerary['package'] contains the result set from database. i have to send the package duration
// according to user when onchange() event will occur

<select name="package_name" id="package_name">        
                      <option value="0">Select Name</option>
                        &lt;?php foreach ($itinerary['package'] as $package) { ?&gt;
                        
                        <option value="&lt;?php echo $package['id'];?&gt;">
                            &lt;?php echo $name['package_name'];
                            // here generates $duration that i have to pass
                            $duration = $package['duration']);  
                            
                            ?&gt;            
                        </option>
                
                        &lt;?php } ?&gt;
</select>
[removed]
function showDayNumber(day)
    {
        document.getElementById("maximum_duration")[removed] = day;
    }
[removed]

<span id="maximum_duration"></span>

// so this span will contain the duration.
// how i can use this value in the following loop?

&lt;?php for ( $i=1; $i <= 'here the value will be set'; $i++ ) { ?&gt;

<div id="itinerary&lt;?php echo $i?&gt;" style="display:none">
        Description: &lt;textarea rows="3" cols="40" name="description[]" id="description"&gt;&lt;/textarea>
</div>
&lt;?php } ?&gt;

    &lt;input type="button" name="add_button" id="add_button" value="Add"&gt;
    &lt;?php echo nbs(3)?&gt;
    &lt;input type="button" name="delete_button" id="delete_button" value="Delete&gt;
    
// actually i have to save description for every day of duration...so i need to pass the total
// duuration and i have to use that value in the loop...

// i can do it in the combo box <option value="&lt;?php echo $duration;?&gt;"> by showDayNumber(this.value)
// but i need the $package['id'] in the next submitted page.
#2

[eluser]Krzemo[/eluser]
wheres question??
#3

[eluser]ranjitbd[/eluser]
[quote author="Cshamoh" date="1260293639"]wheres question??[/quote]
Code:
// $itinerary['package'] contains the result set from database. i have to send the package duration
// according to user when onchange() event will occur

<option value="&lt;?php echo $package['id'];?&gt;">
                            &lt;?php echo $name['package_name'];
// here generates $duration that i have to pass  but how i will pass?
                            $duration = $package['duration']);  
                            
                            ?&gt;            
                        </option>

// so this span will contain the duration.
// how i can use this value in the following loop? commented in the above code


// actually i have to save description for every day of duration...so i need to pass the total
// duuration and i have to use that value in the loop...

// i can do it in the combo box <option value="&lt;?php echo $duration;?&gt;"> by showDayNumber(this.value)
// but i need the $package['id'] in the next submitted page.

all the question is commented inside the code block




Theme © iAndrew 2016 - Forum software by © MyBB