Jump to content
funbinod

jquery .append problem

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

Share this post


Link to post
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

Share this post


Link to post
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...

 

:)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...