IT Community - Software Programming, Web Development and Technical Support

How can I return two values to a form?

This is a discussion on How can I return two values to a form? within the PHP Programming forums, part of the Web Development category; Hi all, I need to return two values of an image's name and price. Here the below is my ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > PHP Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 09-26-2007, 11:27 PM
S.Vinothkumar S.Vinothkumar is offline
D-Web Genius
 
Join Date: May 2007
Posts: 1,061
S.Vinothkumar is on a distinguished road
Question How can I return two values to a form?

Hi all,

I need to return two values of an image's name and price. Here the below is my coding...clear me from my coding....

dbselect Code

Code:
<?php
$q=$_GET["q"];
include "con.php";
$sql="SELECT imgname,price FROM product WHERE no = '".$q."'";
$result = mysql_query($sql);
$row=mysql_fetch_row($result);
$imgpath=$row[0];
echo "<img width='120px' src=$imgpath>";

//Here I need to return the Price field to the parent page

mysql_close($dbh);
?>
JS code

Code:
function stateChanged() 
{ 

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById("layer1").innerHTML=xmlHttp.responseText //shows image correctly here.
 } 
}

In HTML code the text box's name is txtprice

thanking you in advance..
__________________
S.VinothkumaR
Behind me is infinite power,
Before me is Endless Possibility,
Around me is Boundless Opportunity,
Why should I fear!
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 09-27-2007, 03:24 AM
accer accer is offline
D-Web Sr.Programmer
 
Join Date: Sep 2007
Posts: 175
accer is on a distinguished road
Default Re: How can I return two values to a form?

I'm not sure of the fix. I tried this on a test site and couldn't get it to work. I'll keep trying though.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 09-27-2007, 03:35 AM
S.Vinothkumar S.Vinothkumar is offline
D-Web Genius
 
Join Date: May 2007
Posts: 1,061
S.Vinothkumar is on a distinguished road
Default Re: How can I return two values to a form?

Hi accer,

Thanx for your reply. Try and let me know if u got solution.

I'm go thru this in my head for past 4 hrs.
__________________
S.VinothkumaR
Behind me is infinite power,
Before me is Endless Possibility,
Around me is Boundless Opportunity,
Why should I fear!
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 09-28-2007, 02:14 AM
mobilegeek mobilegeek is offline
D-Web Analyst
 
Join Date: Jun 2007
Posts: 205
mobilegeek is on a distinguished road
Default Re: How can I return two values to a form?

$imgprice = $row[1];
echo "<img width='120px' src=$imgpath>" . "|" . $imgprice;


...............

var nResponse = xmlHttp.responseText;
nResponse = nResponse.split("|");
document.getElementById("layer1").innerHTML = nResponse[0];
document.forms[0]['txtprice'].value = nResponse[1];
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 09-28-2007, 02:21 AM
S.Vinothkumar S.Vinothkumar is offline
D-Web Genius
 
Join Date: May 2007
Posts: 1,061
S.Vinothkumar is on a distinguished road
Wink Re: How can I return two values to a form?

Hey geek!

Tanks a lot!....I tried for this past 2 days....

thnk u very much!
__________________
S.VinothkumaR
Behind me is infinite power,
Before me is Endless Possibility,
Around me is Boundless Opportunity,
Why should I fear!
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 10-16-2007, 07:29 AM
ramkumaraol ramkumaraol is offline
D-Web Programmer
 
Join Date: Jul 2007
Posts: 98
ramkumaraol is on a distinguished road
Default Re: How can I return two values to a form?

HI,
Try this code..

echo "<?xml version='1.0' encoding='iso-8859-1'?>
<response>
<imgpath>$path</imgpath>
<imgprice>$price</imgprice>
</response>";
--------------------------

var xml = xmlHttp.responseXML;
var root = xml.documentElement;
path = root.getElementsByTagName("imgpath")[0];
price = root.getElementsByTagName("imgprice")[0];
Thanks,
Ramkumar.B
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date/time stamp a form field as the form is submitted itbarota HTML, CSS and Javascript Coding Techniques 1 02-06-2008 10:16 PM
popup date selector return dates to different form fields. itbarota HTML, CSS and Javascript Coding Techniques 3 01-08-2008 10:19 PM
How can I clear the form field values after the user has submitted the form for clien itbarota HTML, CSS and Javascript Coding Techniques 1 11-01-2007 11:39 PM
How can I pass a hidden value to a form and submit that form when a text link is clic itbarota HTML, CSS and Javascript Coding Techniques 1 10-17-2007 08:07 AM
How to establish a COM event sink with return values in the .NET Framework by using V kingmaker ASP and ASP.NET Programming 0 07-24-2007 12:06 AM


All times are GMT -7. The time now is 05:42 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0