funbinod Posted July 4, 2014 Share Posted July 4, 2014 (edited) 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 July 4, 2014 by funbinod Link to comment Share on other sites More sharing options...
dsonesuk Posted July 4, 2014 Share Posted July 4, 2014 (edited) 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 July 4, 2014 by dsonesuk Link to comment Share on other sites More sharing options...
funbinod Posted July 4, 2014 Author Share Posted July 4, 2014 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now