PHP jQuery with .change how can i combine both? - php

I have this codes with select name=client
with the help of jQuery i want to populate my textbox and other field.
this select helps me to change my client option.
so for example i click the select im going to choice the client B.
after that it will populate the text box and other fields. with the information came from database.
is my code correct, i post question here because i dont know why is my code not working.
my jQuery Codes
<script type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(function(){
jQuery('select[name=client]').change(function(){
var com_code = jQuery(this).val();
<?
$getClient = "SELECT * FROM jon_com_for";
$getClient .= "WHERE com_code=";
$getClient .= "'com_code'";
$setClient = SET_SQL( $getClient );
?>
jQuery('input[name=com_code]').val( '<?=$setClient['com_code'];?>' );
jQuery('input[name=set]').val( '1' );
jQuery('input[name=company_name_for]').val( '<?=$setClient['company_name_for'];?>' );
jQuery('input[name=street_name]').val( '<?=$setClient['street_name'];?>' );
jQuery('input[name=post_code]').val( '<?=$setClient['post_code'];?>' );
jQuery('input[name=city]').val( '<?=$setClient['city'];?>' );
jQuery('input[name=country]').val( '<?=$setClient['country'];?>' );
});
});
</script>
my html code this html was inside of a dialog.
<div id="dialog" title="Step 1">
<form id="submit_steps" method="POST" action="new-template.php">
<input type="hidden" name="user_code" value="<?=$_SESSION['user_code'];?>" />
<input type="hidden" name="com_code" value="<?=comucode();?>" />
<input type="hidden" name="footnote" value="1" />
<input type="hidden" name="set" value="1" />
<div style="margin:20px auto;">
<label for="client">Selecteer klant : </label>
<select name="client">
<?php
$list_of_client = mysql_query( "SELECT * FROM jon_com_for" ) or die ( mysql_error() );
while( $row = mysql_fetch_array( $list_of_client ) ) {
echo '<option value="'.$row['com_code'].'">'.$row['company_name_for'].'</option>';
}
?>
</select>
</div>
<table cellpadding="3" cellspacing="0" width="100%">
<tbody>
<tr>
<td align="right" valign="middle">BEDRIJFSNAAM :</td>
<td><input name="company_name_for" size="30" id="company_name_for" class="input" type="text" /></td>
</tr>
<tr>
<td align="right" valign="middle">ONDERWERP VAN OFFERTE :</td>
<td><input class="input" name="sub_quo" id="sub_quo" size="30" type="text" /></td>
</tr>
<tr>
<td align="right" valign="middle">STRAAT :</td>
<td><input class="input" name="street_name" id="street_name" size="30" type="text" /></td>
</tr>
<tr>
<td align="right" valign="middle">Postcode :</td>
<td><input class="input" name="post_code" id="post_code" size="30" type="text" /></td>
</tr>
<tr>
<td align="right" valign="middle">STAD :</td>
<td><input class="input" name="city" id="city" size="30" type="text" /></td>
</tr>
<tr>
<td align="right" valign="middle">LAND :</td>
<td><input class="input" name="country" id="country" size="30" type="text" /></td>
</tr>
</tbody>
</table>
<div align="center">
<input type="submit" name="save_client_prof" value="Opsslaan" /> or Annuleren</p>
</div>
</form>
</div>
is that correct i put the PHP inside jQuery?
im sorry codes updated
also my dialog is not working anymore.
here are the code that i had changed thank you all...
<script type="text/javascript">
$(function(){
$('select[name=clientx]').change(function(e){
$('<img src="images/ajax-loader.gif" id="loading" style="width:auto;" />').appendTo("#client_details");
//Cancel the link behavior
e.preventDefault();
//Get the A tag
var com_code = $('select[name=clientx]').val();
var dia = jQuery( 'input[name=dia]' ).val();
$.ajax({
type:"GET",
url:"forms/company.php",
data: {dia: dia, com_code: com_code},
dataType: 'html',
target: '#dialog',
success: function(data){
$("#client_details").find('img#loading').remove();
$("#client_details").html(data);
}
})
});
});
</script>

Putting PHP code inside a jQuery change event does not mean that the PHP code is run when the change event happens.
PHP code written this way runs only once, when the page is loaded. This means that it will never know what the com_code JS variable contains after the click.
In order to execute PHP code whenever the JS change event happens, you need to use a technique called Ajax. Your javascript code needs to make a call to an entirely separate PHP program that will query the data and return the results back to the browser for the javascript code to work with.
This technique is well established, and jQuery provides functions that make it very easy to use. Look up some jQuery Ajax examples, and follow them from there.
Hope that helps.

Related

neither required nor pattern is working in html

I am trying to validate the mobile number, email, firstname and etc.. field by using required and pattern keyword but its not responding anything.
In my program there is one input field for mobile number if user has entered mobile number which is not stored in database, then registration page pops up and user should registered for further process and if they entered mobile number which is stored in database then random number is displayed, but when I am entering the values in registration form but it is not validating like I have return required keyword in input field but still its not responding.
Please help me out of this.
Below us my code:
HTML
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<!DOCTYPE html>
<body>
<div>
<form action = "#" method = "post" >
<div>
<legend >Login</legend>
<table id="verify_table" cellpadding="2" cellspacing="2" >
<tr>
<td> Mobile No. </td>
<td><input id="mob" type="tel" name="mobile" required pattern="\[7-9]{1}[0-9]{9}\" /></td>
<td><input type="button" name="verify" class="verify" value="Verify"></td>
</tr>
</table>
</div>
<div id="random" style="display: none;" >
<table id='random_table'>
<tr>
<td>Random Number generated</td>
<td id='rand'>
</tr>
</table>
</div>
<!--Register pop up-->
<div id="reg_light" class="white_content">
<div id="register-title">
<div id="reg-title">
<h6>Register</h6>
</div>
<div id="close">
<a href="javascript:void(0)" onclick="document.getElementById('reg_light').style.display='none';
document.getElementById('fade').style.display='none'; $('#firstname').val('');
$('#lastname').val('');
$('#mobile_number').val('');
$('#email').val('');">X</a>
</div>
</div>
<?php //echo form_open('register'); ?>
<div id="register-inner">
<form id="reg_form" method="POST">
<table id="register_table">
<tr><td><font color="red">* Fields are mandatory</font></td></tr>
<!--<form id="reg_form" onSubmit="return formValidation();">-->
<tr>
<table id="name">
<tr>
<td>First Name<font color="red">*</font></td>
<td><input id="firstname" type="text" placeholder="First Name" name="firstname" required pattern="[A-Za-z]+" ></td>
<td>Last Name<font color="red" >*</font></td>
<td> <input id="lastname" type="text" placeholder="Last Name" name="lastname" required pattern="[A-Za-z]+"></td>
</tr>
</table>
</tr>
<tr><td>&nbsp&nbsp</td></tr>
<tr>
<table id="gen">
<tr>
<td>Gender<font color="red">*</font></td>
<td><input type="radio" name="gender" value="Male"> Male</td>
<td><input type="radio" name="gender" value="Female"> Female</td>
</tr>
</table>
</tr>
<tr>
<table id="mob">
<tr>
<td>Mobile No.<font color="red">*</font></td>
<td><input id="mobile_number" type="text" placeholder="Mobile number" name="mobile_number" required pattern="[7-9]{1}[0-9]{9}" /></td>
<td>Email id<font color="red">*</font></td>
<td> <input id="email" type="email" placeholder="Email-id" name="email" required pattern="[A-Za-z]+[0-9]+#[A-Za-z]+.[A-Za-z]+"> </td>
</tr>
</table>
<table id="submit">
<tr>
<td id="errorBox"></td>
<td><input class="reg_data" id="submit" type="button" name="submit" value="Register"></td>
</tr>
</table>
</tr>
</table>
</form>
</div>
</body>
</html>
Here is my jQuery code
$(document).ready( function() {
$('.verify').click(function(){
var mob = $('#mob').val();
//alert(mob);
$.ajax({
url: "<?php echo base_url(); ?>/login/verify",
data: {'mob_no': mob},
type: "post",
cache: false,
success: function (data)
{
//alert(data);
var obj = $.parseJSON(data);
var fi="";
var otp="";
var rand="";
rand+=Math.floor(100000 + Math.random() * 99999);
$.each(obj, function()
{
fi=this['id'];
});
if(!fi=="")
{
//document.getElementById("random").innerHTML=random_number;
$('#rand').val(rand);
document.getElementById("rand").innerHTML=rand;
document.getElementById('random').style.display='block';
}
else
document.getElementById('reg_light').style.display='block';
document.getElementById('fade').style.display='block';
//alert(fi);
}
},
error: function (xhr, ajaxOptions, thrownError) {
//alert(thrownError);
}
});
});
});
Reset the form validation, after making the form visible
function resetFormValidator(formId) {
$(formId).removeData('validator');
$(formId).removeData('unobtrusiveValidation');
$.validator.unobtrusive.parse(formId);
}
For Dynamically created dom
Use
$(document).on('click','#id',function(){
// do somethings
})

Not able to reset the input field jquery php wordpress

I need to reset the field onclick of reset button
But I am not able to do that.
Here is my html code
<table cellspacing="2" cellpadding="5" style="width: 100%;" class="form-table1" id="form-table1" >
<tbody>
<tr class="form-field1">
<th valign="top" scope="row">
<label for="approved_mailCc"><?php _e('OpenLab Cc', 'custom_table_example')?></label>
</th>
<td>
<input id="approved_mailCc" name="approved_mailCc" type="email" value="<?php echo isset($item['approved_mailCc']) ? $item['approved_mailCc'] : ''; ?>"
size="50" class="code" placeholder="<?php _e('OpenLab Cc', 'custom_table_example')?>" required />
<input type="button" value="Reset" id="approved_mailCc" name="openLab"/>
</td>
</tr>
jQuery code
jQuery(document).ready(function($){
console.log("plugin script loaded2");
$('#approved_mailCc').click(function(){
$(this).val('');
});
});
1 I am getting console log.
2 alert is not going inside onclick
3 i used reset function also.
You have two inputs with the same ID of "approved_mailCc" you can't have more than one item with the same ID, it will confuse jQuery. Give them unique IDs like below:
<table cellspacing="2" cellpadding="5" style="width: 100%;" class="form-table1" id="form-table1" >
<tbody>
<tr class="form-field1">
<th valign="top" scope="row">
<label for="approved_mailCc"><?php _e('OpenLab Cc', 'custom_table_example')?></label>
</th>
<td>
<input id="approved_mailCc_email" name="approved_mailCc" type="email" value="<?php echo isset($item['approved_mailCc']) ? $item['approved_mailCc'] : ''; ?>"
size="50" class="code" placeholder="<?php _e('OpenLab Cc', 'custom_table_example')?>" required />
<input type="button" value="Reset" id="approved_mailCc_button" name="openLab"/>
</td>
</tr>
and then use this jQuery code:
jQuery(document).ready(function(){
console.log("plugin script loaded2");
jQuery('#approved_mailCc_button').click(function(){
jQuery('#approved_mailCc_button_email').val('');
});
First, you are not supposed to need Javascript to reset a form (but you need the tag) :
https://jsfiddle.net/9xfonyou/
Second, there are errors on your code double IDs.
Here "approved_mailCc" is both your input file and your button. Then you can do this in Javascript to make it work.
HTML :
<form>
<table cellspacing="2" cellpadding="5" style="width: 100%;" class="form-table1" id="form-table1">
<tbody>
<tr class="form-field1">
<th valign="top" scope="row">
<label for="approved_mailCc"></label>
</th>
<td>
<input id="input_field" name="approved_mailCc" type="email" value="" size="50" class="code" placeholder="test" required />
<input type="reset" id="reset_button" name="openLab" />
</td>
</tr>
</tbody>
</table>
</form>
JS :
jQuery(document).ready(function($) {
console.log("plugin script loaded2");
$('#reset_button').click(function(e) {
e.preventDefault();
$('#input_field').val('');
});
});
https://jsfiddle.net/9xfonyou/1/

adding input box dynamically when filling the other input box

i have a form like this
<FORM method="post">
<TABLE>
<TR>
<TD>Username</TD>
<TD><INPUT type="text" value="" name="username" title="Enter Username"/><TD>
</TR>
<TR>
<TD>Age</TD>
<TD><INPUT type="text" value="" name="username" title="Enter Age"/><TD>
</TR>
<TR>
<TD>City</TD>
<TD><INPUT type="text" value="" name="username" title="Enter City"/><TD>
</TR>
<TR>
<TD>Comment</TD>
<TD><INPUT type="text" value="" name="username" title="Enter Comment"/><TD>
</TR>
</TABLE>
</FORM>
what i want is when user after filling the comment box ,when they press enter then dynamically another input box has to display with comment label by using javascript.
can anyone help me to write the code...
Try this my friend:
<FORM method="post">
<TABLE>
<TR>
<TD>Username</TD>
<TD><INPUT type="text" value="" name="username" title="Enter Username"/><TD>
</TR>
<TR>
<TD>Age</TD>
<TD><INPUT type="text" value="" name="age" title="Enter Age"/><TD>
</TR>
<TR>
<TD>City</TD>
<TD><INPUT type="text" value="" name="city" title="Enter City"/><TD>
</TR>
<TR>
<TD>Comment</TD>
<TD><INPUT class="comment" type="text" value="" name="comment[]" title="Enter Comment"/><TD>
</TR>
</TABLE>
</FORM>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>
$(function(){
$('.comment').live('keydown', function(e){
$field = $(this);
// capture enter key being pressed
if (e.which == 13)
{
$html = $(this).parents('tr').clone();
$html.find('input').val('');
$html.appendTo($field.parents('table'));
}
});
});
</script>
First of all your all the input names in your form are the same (name="username"), you have to give each input a unique name.
so change comment input to
<TR id="comment">
<TD>Comment</TD>
<TD><INPUT type="text" value="" name="comment[]" title="Enter Comment"/><TD>
</TR>
note that i added id to the TR so it'll be easier to latch on to it using jquery and i also changed the input name to be comment[] since if you add a new comment to the dom you'll have a comment array.
if the new comment should have a new name like : 'comment2', you can change it to be just 'comment'
Now, using Jquery do the following:
$(document).keypress(function(e) {
//catch enter event
if(e.which == 13) {
var $comment = $('#comments);
//check that the user entered something in the comment input
if($comment.find('input').val().length > 0)
{
//create new comment element and attach it to DOM
var $newComment = $comment.clone().removeAttr('id');
$('form table').append($newComment);
}
}
});
let me know if that helped or if you need more info.

Why isn't Recaptcha showing up from PHP using XMLHttpRequest?

::EXPLINATION::
In an HTML file, I'm attempting to load a registration frame with a captcha check. The form itself shows up. The captcha does not. So I know that the javascript (posted below) gets what I want it to get. But there's something wrong that is keeping my captcha from showing up.
Just as a final note, I'm targetting a div with the id "splashTarget" I use CSS to arrange everything how I want it. I'm not going to post that because its probably not relevant, but if you think I do need to post it to get help let me know.
::CODE::
The form that doesn't seem to work:
<div class="splash"> </div>
<div style="text-align:left" id="registrationSplash" class="splashContent">
<div style="text-align:right">
<a style="color:darkred" href="javascript:closeSplash()">[ CANCEL ]</a>
</div>
<h1>REGISTER</h1>
<form action="" method="post" id="registerForm">
<?PHP
require_once('recaptchalib.php');
$publickey = "[censored]";
echo recaptcha_get_html($publickey);
echo '<!--'.recaptcha_get_html($publickey).'-->';
?>
<table>
<tr>
<td>First Name:</td>
<td><input type="text" name="firstname" maxlength="60"></td>
<td>Username:</td>
<td><input type="text" name="username" maxlength="30"></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type="text" name="lastname" maxlength="60"></td>
<td>Password:</td>
<td><input type="password" name="pass" maxlength="30"></td>
</tr>
<tr>
<td>E-mail Address:</td>
<td><input type="text" name="firstname" maxlength="60"></td>
<td>Confirm Password:</td>
<td><input type="password" name="pass2" maxlength="30"></td>
</tr>
<tr>
<th colspan=4 style="text-align:right">
<button onclick="submitFormRegisterSplash()" type="button" name="submit" value="Login">Register!</button>
</th>
</tr>
</table>
</form>
<div id="status" />
</div>
The actual call to recaptia.
<?PHP
require_once('recaptchalib.php');
$publickey = "[censored]";
echo recaptcha_get_html($publickey);
echo '<!--'.recaptcha_get_html($publickey).'-->';
?>
Javascript Function used to load Register form:
function onRegisterClicked() {
var onRegisterClickedHttp;
if(window.XMLHttpRequest) {
onRegisterClickedHttp = new XMLHttpRequest();
onRegisterClickedHttp.onreadystatechange = function() {
if(onRegisterClickedHttp.readyState==4 && onRegisterClickedHttp.status==200) {
var response = onRegisterClickedHttp.responseText;
document.getElementById("splashTarget").innerHTML = response;
}
}
}
onRegisterClickedHttp.open("GET", "Verification/RegisterSplash.php", true);
onRegisterClickedHttp.send();
}
Result on Webpage after calls to create
<div id="splashTarget">
<div class="splash"> </div>
<div style="text-align:left" id="registrationSplash" class="splashContent">
<div style="text-align:right">
<a style="color:darkred" href="javascript:closeSplash()">[ CANCEL ]</a>
</div>
<h1>REGISTER</h1>
<form action="" method="post" id="registerForm">
<script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=6LehEsgSAAAAAAH2xfKSXKSdldMwoiOqZyO5TupV"></script>
<noscript>
<iframe src="http://www.google.com/recaptcha/api/noscript?k=6LehEsgSAAAAAAH2xfKSXKSdldMwoiOqZyO5TupV" height="300" width="500" frameborder="0"></iframe><br/>
<textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
<input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
</noscript><!--<script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=6LehEsgSAAAAAAH2xfKSXKSdldMwoiOqZyO5TupV"></script>
<noscript>
<iframe src="http://www.google.com/recaptcha/api/noscript?k=6LehEsgSAAAAAAH2xfKSXKSdldMwoiOqZyO5TupV" height="300" width="500" frameborder="0"></iframe><br/>
<textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
<input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
</noscript>--> <table>
<tbody><tr>
<td>First Name:</td>
<td><input type="text" name="firstname" maxlength="60"></td>
<td>Username:</td>
<td><input type="text" name="username" maxlength="30"></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type="text" name="lastname" maxlength="60"></td>
<td>Password:</td>
<td><input type="password" name="pass" maxlength="30"></td>
</tr>
<tr>
<td>E-mail Address:</td>
<td><input type="text" name="firstname" maxlength="60"></td>
<td>Confirm Password:</td>
<td><input type="password" name="pass2" maxlength="30"></td>
</tr>
<tr>
<th colspan="4" style="text-align:right">
<button onclick="submitFormRegisterSplash()" type="button" name="submit" value="Login">Register!</button>
</th>
</tr>
</tbody></table>
</form>
<div id="status">
</div>
</div></div>
The Website in action is gumonshoe dot net slash Registration
You'll need to choose to try to register to see the pop up. I disabled the CSS that created the splash screen thinking that it might have been an issue with z-indexes. That doesn't appear to be the case.
Thanks for any tips.
The form HTML DOES work (see http://jsfiddle.net/5p5K3/). The error is caused by a feature:
<script> tags which are injected using .innerHTML = .... <script> are not parsed (functions and variables inside these tags are not defined, nor called). You have to include the CAPTCHA code inside the page, instead of adding it using AJAX.
EDIT
Add this HTML code (inside the <head> block):
<script type="text/javascript" src="http://www.google.com/recaptcha/api/js/recaptcha_ajax.js"></script>
Overwrite your function by my suggestion (replace <PUBLIC kEY HERE> by your public key):
function onRegisterClicked() {
Recaptcha.create("<PUBLIC KEY HERE>", "splashTarget", {
theme: "red",
callback: Recaptcha.focus_response_field
});
}
Obvious problem: The inserted recaptcha code is commented out with <!-- -->. Commented-out html/js is NOT going to be rendered/executed. Change
echo '<!--'.recaptcha_get_html($publickey).'-->';
to
echo recaptcha_get_html($publickey);

Need some resoultion. Javascript function not being called in click event in jquery

I am trying to call my function named isUrgencyTypeValid from my javascript code but it is not working. Please check what is the problem in my code.
Alert should get displayed which is not being displayed
My javascript function is not being called.
HTML Code
<td colspan="2" align="center"><input id="btnSubmit" type="submit" value="submit" runat="server"/></td></tr>
jQuery Call function
$("#btnSubmit").bind("click",function(){
alert(); // this is running
isUrgencyTypeValid();
});
javascript implemented function
function isUrgencyTypeValid()
{
alert("asd");
var i=0;
for(i=0;i<$("radio[name='urgencyType']").length;i++)
{
if($("radio[name='urgencyType']")[i].checked)
{
alert($("radio[name='urgencyType']")[i].value);
return true;
}
return false;
}
More description about my form is here
<form runat="server" name="myPage">
<table style="width: 100%;" cellpadding="5" cellspacing="5">
<caption>
Computer Support / Service Request
</caption>
<tr><td>First Name</td>
<td><input id="txtFirstName" type="text" value="First Name" runat="server"/><span class="error"></span></td></tr>
<tr>
<td>Last Name</td>
<td><input id="txtLastName" type="text" value="Last Name" runat="server"/><span class="error"></span></td></tr>
<tr>
<td>Email Address</td>
<td><input id="txtEmailAddress" type="text" value="Email Address" runat="server"/><span class="error"></span></td></tr>
<tr>
<td>Phone No</td>
<td><input id="txtPhoneNo" type="text" value="Phone No" runat="server" /><span class="error"></span></td></tr>
<tr>
<td>Do you have text messaging</td>
<td>
<span>Yes</span><input id="rdoYes" value="Yes" type="radio" runat="server"/>
<span>No</span><input id="rdoNo" value="No" type="radio" runat="server"/><span class="error"></span>
</td></tr>
<tr>
<td>Description of request*: </td>
<td><textarea id="txtDescription" cols="50" rows="10" runat="server"></textarea><span class="error"></span><span id="lengthCount"></span></td></tr>
<tr>
<td>Urgency of this support request:</td>
<td>
<input id="rdoAnyTime" name="urgencyType" value="Anytime" type="radio" runat="server"/><span>Anytime</span><br />
<input id="rdoCplDays" name="urgencyType" value="In the next couple of days" type="radio" runat="server"/><span>In the next couple of days</span><br />
<input id="rdoToday" name="urgencyType" value="Today" type="radio" runat="server"/><span>Today</span><br />
<input id="rdoUrgent" name="urgencyType" value="This is extremely urgent...I cannot wait!" type="radio" runat="server"/><span>This is extremely urgent...I cannot wait!</span><br />
<input id="rdoTalkSometime" name="urgencyType" value="Please contact me and we'll talk about it" type="radio" runat="server"/><span>Please contact me and we'll talk about it</span><br /><span class="error"></span>
</td></tr>
<tr>
<td colspan="2" align="center">Captcha To Be implemented.</td></tr>
<tr>
<td></td>
<td><input id="chkRequestCopy" type="checkbox" runat="server"/>Please send me a copy of this service request</td></tr>
<tr>
<td colspan="2" align="center"><input id="btnSubmit" type="submit" value="submit" runat="server"/></td></tr>
</table>
</form>
I copied your code and ran into the same issue. Then I looked at it closer and noticed you are missing a closing bracket in your isUrgencyTypeValid() function. The closing bracket for your for loop is missing. Firefox Error Console will also show this.
Once I added the bracket the alert worked fine.
function isUrgencyTypeValid()
{
alert("asd");
var i=0;
for(i=0;i<$("radio[name='urgencyType']").length;i++)
{
if($("radio[name='urgencyType']")[i].checked)
{
alert($("radio[name='urgencyType']")[i].value);
return true;
}
} //this was missing
return false;
}
Your radio selector is incorrect.
There's not such thing as a radio element, but there is a :radio pseudo-class selector.
Your code should read:
function isUrgencyTypeValid()
{
alert("asd");
var i=0;
for(i=0;i<$("input[name='urgencyType']:radio").length;i++)
{
if($("input[name='urgencyType']:radio")[i].checked)
{
alert($("input[name='urgencyType']:radio")[i].value);
return true;
}
return false;
}
** EDIT **
In addition to the changes above, since the alert never occurs, this indicates that isUrgencyTypeValid is not being called.
The most likely explanation is that you're not waiting until the DOM is loaded, before you bind the your handler to the click event of the button. You should have some code somewhere that looks like this:
$(function()
{
/*
* ... other code ...
*/
$("#btnSubmit").bind("click",function(){
isUrgencyTypeValid();
});
/*
* ... other code ...
*/
}

Categories