Jump to content

jquery .append problem


funbinod

Recommended Posts

i'm trying to append some elements with some conditions

<script type="text/javascript">function appending() {	if ($('#ac_type').value == "Debtors") {		$("#append").append( "<p>Test Append Element</p>" );	}}</script>

i take value for the if condition and append onBlur from this --

        	<select name="ac_type" id="ac_type" onkeypress="return tabE(this,event)" onBlur="appending()" />            	<option></option>				<?php				$query = "SELECT * FROM ac_type";				$result = mysqli_query($connect, $query) or die("Unable to select database: " . mysqli_error($connect));				while ($row = mysqli_fetch_array($result)) { echo "<option>" . $row['ac_type'] . "</option>"; }				?>            </select>

i append the element here--

    <tr valign="top">    	<td colspan="2"><div id="append"></div></td>    </tr>

but its not working with the defined condition. but if i remove the condition [ if ($('#ac_type').value == "Debtors") { ] it works......

 

please guide where i did wrong....

Edited by funbinod
Link to comment
Share on other sites

if ($('#ac_type').val() == "Debtors")

 

 

edit: just noticed you are self closing the select also.

 

<select name="ac_type" id="ac_type" onkeypress="return tabE(this,event)" onBlur="appending()" />

Edited by dsonesuk
Link to comment
Share on other sites

upppsssss! sorry! sorry!

 

i just forgot i'm using jQuery and i used javascript's 'value'. it worked now. thank u.

 

and thank u again for correcting me on select element...

 

:)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...