Jump to content


Check out our Community Blogs

rushhh

Member Since 08 Mar 2009
Offline Last Active Mar 04 2010 07:38 PM
-----

Topics I've Started

Add another row

27 February 2010 - 09:41 AM

Hi I hope this is the right place to post the question, if not please let me know where to post it.

I'm using a javascript that add another row to a table, the adding work but I'm trying figure out how to remove only 1 row at a time, right now its remove all at the same time. And is there a way I can add a remove link at each line that has been added?

<script type="text/javascript"> 
$(function(){
var current = 1; 

$('#addPerson').click(function(){
	current++;
	
	var strToAdd = '<div class="add"><table width="450px" cellpadding="0" cellspacing="0" border="0"><tr><td width="108"><label for="flavour"'+current+'">Flavour name:</label></td><td> <input id="flavour[]'+current+'" name="flavour[]'+current+'" size="0" /></td></tr>'
	strToAdd += '<tr><td><label for="size"'+current+'">Size:</label></td><td>  <input id="size'+current+'" name="size[<? $i ?>]'+current+'" size="0" /></td></tr>'
	strToAdd += '<tr><td><label for="upc'+current+'">UPC:</label></td><td><input id="upc'+current+'" name="upc[<? $i ?>]'+current+'" size="0" /></td></tr></table></div>'
	//strToAdd += ''+current+''
	
	$('.mainField').append(strToAdd);
		});
});
$(function(){
$('#remove').click(function(){
	$('.add').remove();
	//alert(current)
	//current = -1; 
	
	}); 
});
</script>

Thanks for your help...

Sending a ajax input element array

13 December 2009 - 08:54 AM

HI I'm tring to fingure out how to send input element array to jQuery ajax $.post.
my input element array looks like =
"<input type="text" name="name[]" id="name[]">"

I'm also using a jQuery plugin to another box to the name input
something like this -
coldfusionjedi.com/index.cfm/2009/2/19/Using-jQuery-to-add-form-fields "Raymond Camden's ColdFusion Blog: Using jQuery to add form fields"

Here is the code I'm trying to uses.
$(document).ready(function()
{
	$("#myform").submit(function()
	{	$("#msgbox3").removeClass().addClass('messagebox').text('Adding....').fadeIn(1000);
		$.post("senddata.php",{ 
					nane:$('#nane').val(),
					} ,function(data)
        {
		  if(data=='yes') //if correct login detail
		  {
		  	  alert(data);
		  	$("#msgbox3").fadeTo(200,0.1,function()  //start fading the messagebox
			{ 
			  $(this).html('New name has been added...').addClass('messageboxok').fadeTo(900,1,
              function()
			  { 
				 $.unblockUI();
			  });
			  
			});
		  }
		  else 
		  {
		  	  alert(data);
		  	$("#msgbox3").fadeTo(200,0.1,function() //start fading the messagebox
			{ 
			  $(this).html('That name has already been added...').addClass('messageboxerror').fadeTo(900,1);
			});		
          }			
        });
 		return false;
	});
	$("#add_btm").blur(function()
	{
		$("#add_form").trigger('submit');
	});
});
</script>
senddata.php:
<?php 
print_r ($_POST)
?>
When it alerts, it displays as.
Array {
[name] => undefined
}

How can I send the array though ajax?

Thanks

Submit two forms with one button

25 July 2009 - 05:45 AM

Hope this the right place to post this question.

I'm trying to Submit two forms with one button and one by one. Submit one by one is working. But can't finger out how to submit both at the same time.

<script type="text/javascript">
function f1Submit()  {
var n1 = document.f1.t1.value;
var n2 = document.f2.t2.value;
	if (!n1)  {
		document.f2.t2.value = n2;
		document.f2.action="/test2.php"
		document.f2.submit();
	}
	else if (!n2)  {
	document.f1.t1.value = n1;
	document.f1.action="/test2.php"
	document.f1.submit();
	}
	else if (n1 && n2){   //Submitting at the same time.
		alert ("hello");
	document.f1.t1.value = n1;
	document.f2.t2.value = n2;
	document.f1.action="/test2.php"
	document.f2.action="/test2.php"
	document.f1.submit();
	document.f2.submit();
	
	}
}
function submitAll() {
f1Submit();
}                                                          
</script>
</HEAD>

<BODY onload="document.f1.t1.focus();">
<form name="f1" method="get"  enctype="multipart/form-data">

F1 NAME: <input type="text" name="t1"  size="24"  />
</form>

<form name="f2" method="get"  enctype="multipart/form-data">
 
F2 NAME: <input type="text" name="t2"  size="24"  />
</form>

<form name="allSubmit">
<input type="button"  name="btn1"  value="Submit"  onClick="submitAll()" />
</form>

Thanks

php Array to html table

08 March 2009 - 05:16 PM

Hi everyone. I'm fetch data from mysql then displaying it in html table.

The data in the mysql is:
Banana, 2 LBS
Creme, 2 LBS
Brownie, 2 LBS
Batter, 2 LBS
Blueberry, 2 LBS
Milk, 2 LBS

Brownie, 5 LBS
Batter, 5 LBS
Blueberry, 5 LBS
Milk, 5 LBS

Tring to get it to display as

2 LBS
Banana Creme
Brownie Batter
Blueberry Milk

5 LBS
Brownie Batter
Blueberry Milk

Right now in table "2 LBS" its displaying everything, but in table "5 LBS" its disaplaying 4 names of "2 LBS", how can I get table "5 LBS" to only display what in "5 LBS"?

Here my code:
$query=mysql_query("select size from $tb4_name WHERE product_id='$uid' Group by size");
while($order=mysql_fetch_row($query))
while (list ($key, $val) = each ($order)){

echo $val; //echo the sizes "2 LBS" and "5 LBS" to make the header of the tables

$query2=mysql_query("SELECT * FROM $tb4_name WHERE product_id='$uid' and size = '$val' ORDER BY size, name");
$count = mysql_num_rows($query2);
while ($row1=mysql_fetch_array($query2)) {
$array1[] = ($row1['name']);

echo "<table border='1' width='250'>";
for($i = 1; $i <= $count; $i = $i + 2)
{
echo "<tr><td>{$array1[$i]}</td><td>{$array1[$i+1]}</td></tr>";
}
echo "</table>";
}}


Thanks

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download