barbs75 Posted July 31, 2008 Share Posted July 31, 2008 Hey guys, Right, i will start with what i am trying to do. I have a javascript function which clones some HTML which i have on my page(which is some input fields) that allow a user to enter bedroom details of their house. This runs on the <body onload=""> tag, and works fine. But what i want to do is then fill these fields with data of the house, retrieved using mysql from my database. To go though each of the bedrooms on the database and fill in all the data in the fields requires a while loop to cycle through each bedroom and then add the data to each bedroom at a time... This is where my problem is, as i want to do this automatically when the page is loaded. Hence why i am looking at AJAX. I don't know a lot about AJAX, i have read w3schools stuff, and did a tutorial for the suggestion tool, which i understood, but can't understand how i can use that knowledge for my parrticular problem. How do i use AJAX to call my php script (while loop) and put the data into my input fields?? any help would be great, i have been mightily stuck on this for a while now cheers guys Craig Quote Link to comment Share on other sites More sharing options...
rhodesa Posted July 31, 2008 Share Posted July 31, 2008 AJAX is a great tool, but sometimes over used. before i get into how to use AJAX to fill in the fields, i have to ask... is there are reason you aren't filling them in dynamically with PHP? so when the person loads the page, the values are already in there? Quote Link to comment Share on other sites More sharing options...
barbs75 Posted July 31, 2008 Author Share Posted July 31, 2008 Hey, I'm not sure how i can do it with just php?!? Unless im totally missing something, i think i have been trying to sort this out for SO long, i have lost my mind AND my way a little bit... The fields are generated by javascript, and then for each room that is developed in that javascript has two input fields and one textarea. So i need to pull the data from the database for each bedroom, and then somehow put the 3 pieces of data for each room into the input fields and textrea, but i really don't know how i can achieve this? I know you can put an echo into the value="" of the input field, but somehow i need to loop through each bedroom....ahhhhhh i really don't know how to go about this... Do you know a way of doing this at all?? your help will be greatly received Cheers Craig Quote Link to comment Share on other sites More sharing options...
rhodesa Posted July 31, 2008 Share Posted July 31, 2008 the normal process for this is without javascript at all.... <html> <body> <h1>Bedrooms</h1> <?php //I assume you are connected to MySQL already... $sql = "SELECT * FROM berooms"; $result = mysql_query($sql) or die("Failed to query bedrooms: ".mysql_error()); while($row = mysql_fetch_assoc($result)){ ?> <div> Bedroom name: <?php echo htmlspecialchars($row['name']); ?><br /> <input type="text" name="field1[]" value="<?php echo htmlspecialchars($row['field1'])' ?>" /><br /> <input type="text" name="field2[]" value="<?php echo htmlspecialchars($row['field2'])' ?>" /><br /> <textarea name="field3[]"><?php echo htmlspecialchars($row['field2'])' ?></textarea> </div> <?php } ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
barbs75 Posted July 31, 2008 Author Share Posted July 31, 2008 Hey, Ok, feel slightly thick at this moment...... You see i used javascript to clone my fields when they upload their house details, in this case they are editing their house, so what i am doing is storing a variable in the url when go to edit the property, so if that variable (function='edit') is edit then it gets all the data from the database and displays it when the page is loaded, so they can see what they have entered, and if any changes are made, the database is updated accordingly. So i got stuck into the notation of re-using my code, hence why i was trying to do exactly what you have done, but calling the javascript within the while loop, which obviously can't be done.... Argggh!! ok, i will give this a go, cheers!! Craig Quote Link to comment Share on other sites More sharing options...
rhodesa Posted July 31, 2008 Share Posted July 31, 2008 there are lots of ways to do this...i'm just trying to figure out the best option for you. i like to design my sites to work without javascript, and then add it in after to make it more user friendly. if you post some code, i might get a better idea of what you are trying to accomplish. Quote Link to comment Share on other sites More sharing options...
barbs75 Posted July 31, 2008 Author Share Posted July 31, 2008 ok, I will show you my page of code which i am working on: <?php //turn on sessions session_start(); header("Cache-control: private"); //collect data of whether the user is uploading or editing $function = $_GET['do']; //Receive house_id from URL $house_id = $_GET['id']; //checking if user is logged in, if not send them to login screen if (!$_SESSION['username']) { include("function/login.php"); exit(); } //checking that the user has completed stage 1 $stage = (int) $_SESSION['stage']; if (!$stage == 2)//if they haven't { header("Location: house_upload.php");//send them back to stage 1 //NEED TO STORE AN ERROR MESSAGE HERE TO DISPLAY ON STAGE 1 INDICATING THE USER THAT THEY HAVEN'T COMPLETED STAGE 1 YET!! } $clickCount; if($function == 'edit'){ include('editProperty_fns.php'); require_once('database.php'); //mysql statement to read users data from database to retrieve details $query_house = mysql_query("SELECT * FROM house WHERE house_id = '$house_id'"); $query_bed = mysql_query("SELECT * FROM bedrooms WHERE house_id = '$house_id'"); $query_room = mysql_query("SELECT * FROM rooms WHERE house_id = '$house_id'"); $query_bath = mysql_query("SELECT * FROM bathrooms WHERE house_id = '$house_id'"); $house_info = mysql_fetch_array($query_house); $bedroom_info = mysql_fetch_array($query_bed); $room_info = mysql_fetch_array($query_room); $num_houses = mysql_num_rows($query_house); $num_bedrooms = mysql_num_rows($query_bed); $num_bathrooms = mysql_num_rows($query_bath); } include('function/login_status.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="Style1.css" /> <!--[if IE]> <link rel="stylesheet" type="text/css" href="ie7.css" /> <![endif]--> <link rel="icon" href="Images/favicon.ico" type="image/x-icon" /> <link rel="shortcut icon" href="Images/favicon.ico" type="image/x-icon" /> <title>Property Manager - House details</title> <meta name="Description" content="Find your dream property online, Search for any property for sale in a range of areas in the UK with go4home" /> <meta name="Keywords" content="Find a property, find property, find property in UK, search for a property, Property up for sale, find property up for sale, Property market, Advertise your home to sell, go4home.co.uk, go4home" /> <script type="text/javascript"> /*<![CDATA[*/ function create_fields(nr,roomType){ var root=document.getElementById(roomType); var allB=[], allD=root.getElementsByTagName('div'), i=0, d; // set the collection of the elements with className=inputfield while(d=allD[i++]){ d.className=='inputfield'?allB[allB.length]=d:null; } //removes all the elements, except the first for(var j=allB.length-1;j>=1;j--){ allB[j].parentNode.removeChild(allB[j]); } if(nr==1){return}//stops if a single bedroom is selected var clone;//the clone var tags={'label':['for'],'input':['id','name'],'textarea':['id','name'],'p':[null]} var obj, o, m, a, c; for(var k=2;k<nr+1;k++){ clone=allB[0].cloneNode(true); for(p in tags){ obj=clone.getElementsByTagName(p);m=0; while(o=obj[m++]){ for(var q=0;q<tags[p].length;q++){ if(p=='p'&&o.className=='largeblack'){ c=o.getElementsByTagName('strong')[0].firstChild; c.nodeValue=c.nodeValue.replace(/_1/,'_'+k); } else if(p!='p'){ a=o.getAttribute(tags[p][q]); o.setAttribute(tags[p][q],a.replace(/1/,k)); } } } } root.appendChild(clone); } } // This function will autofill form fields values function autofill(width,height,description) { document.forms.namedItem('upload_stage2').elements.namedItem('bedroom[1][]').value = width; document.forms.namedItem('upload_stage2').elements.namedItem('bedroom[1][]').value = length; document.forms.namedItem('upload_stage2').elements.namedItem('bedroom[1][]').value = description; } /*]]>*/ </script> <script type="text/javascript"> var count = 0; function generate_room(){ count += 1; var num = count; document.getElementById('rooms').appendChild(create_inputfield(num)); document.getElementById('deleteRoom').style.visibility = 'visible'; return count; } //function to create inputfield div and all xhtml content inside function create_inputfield(num){ //create xhtml for inputfield element declaration var inputfield = document.createElement('div'); var divClassName = 'inputfield';//set classname inputfield.className = divClassName;//add class and class name to inputfield var inputfieldContent = '<p class="largeblack"><strong>Added Room '+num+'</strong></p><label class="room" for="extraroom_name_'+num+'">Type:</label><select class="open" name="extraroom['+num+'][0]" id="extraroom['+num+'][0]"><option class="open">--Please Select--</option><option class="open" value="study">Study</option><option class="open" value="games">Games Room</option><option class="open" value="Reception">Reception</option><option class="open" value="conservatory">Conservatory</option></select><br /><br />';//variable containing xhtml content inputfield.innerHTML = inputfieldContent;//adds xhtml content to inputfield inputfield.appendChild(create_dimensiondiv(num));//adds on element created by function inputfield.appendChild(create_descriptionHolder(num));//adds on element created by function return inputfield;//return variable inputfield } //function to create dimensions div function create_dimensiondiv(num){ var dimensiondiv = document.createElement('div'); var divClassName = 'dimensions'; dimensiondiv.className = divClassName; dimensiondiv.innerHTML = '<label class="room" for="extraroom['+num+'][1]">Dimensions:<br/><span class="textSmallGreen">(in feet)</span></label><input class="open" name="extraroom['+num+'][1]" id="extraroom['+num+'][1]" type="text" size="5" value="" /> x <input class="open" name="extraroom['+num+'][2]" id="extraroom['+num+'][2]" type="text" size="5" value="" />'; return dimensiondiv; } //function to create descriptionHolder div function create_descriptionHolder(num){ var descriptionHolder = document.createElement('div'); var divClassName = 'descriptionHolder'; descriptionHolder.className = divClassName; descriptionHolder.innerHTML = '<label class="room" for="extraroom['+num+'][3]">Description:<br/><span class="textSmallGreen">(max. 100 words)</span></label><textarea class="open" name="extraroom['+num+'][3]" id="extraroom['+num+'][3]" size="100" cols="35" rows="5">Enter your description here.....</textarea>'; return descriptionHolder; } function remove_room(theClass) { var allPageTags = document.getElementById('rooms').getElementsByTagName("*"); for(var i=allPageTags.length-1;i>=0;i--){ if(allPageTags[i].className==theClass){ allPageTags[i].parentNode.removeChild(allPageTags[i]);break } } } </script> </head> <body> <div id="mainContainer"> <div id="container-Content"> <div id="content-TopContent"> <?php if(isset($_SESSION['username'])){ show_loginBar(); }else{ show_normalBar($current_page); } ?> <!--End of TopBar --> <div id="navigation-wrapper"> <ul id="nav"> <li class="home"> <ul class="secondlevel"> <li class="nav"><a class="nav" href="index.php">Home of site</a></li> </ul> <li class="search"> <ul class="secondlevel"> <li class="nav"><a class="nav" href="displayhouses.php">Properties for sale</a></li> <li class="nav"><a class="nav" href="">Search criteria</a></li> </ul> </li> <li class="moneyMarket"> <ul class="secondlevel"> <li class="nav"><a class="nav" href="">Expert advice</a></li> <li class="nav"><a class="nav" href="">Home insurance</a></li> <li class="nav"><a class="nav" href="">What can you afford?</a></li> </ul> </li> <li class="goBuy"> <ul class="secondlevel"> <li class="nav"><a class="nav" href="">Search properties</a></li> <li class="nav"><a class="nav" href="">Buyer's guide</a></li> </ul> </li> <li class="goSell"> <ul class="secondlevel"> <li class="nav"><a class="nav" href="house_upload.php">List a property</a></li> <li class="nav"><a class="nav" href="">Seller's guide</a></li> </ul> </li> <li class="help"> <ul class="secondlevel"> <li class="nav"><a class="nav" href="">Contact us</a></li> <li class="nav"><a class="nav" href="">About go4home</a></li> <li class="nav"><a class="nav" href="">Frequently Asked Questions</a></li> <li class="nav"><a class="nav" href="">Technical guide</a></li> <li class="nav"><a class="nav" href="">Terms & Conditions</a></li> </ul> </li> </ul> </div><!--End of navigation-wrapper--> </div><!--End of content-Topcontent --> <div id="profileBar"> <div id="userInfoLarge"><h2 class="shadow" title="<?php echo $_SESSION['username'] ?>"><b><?php echo $_SESSION['username'] ?></b></h2></div> <div id="userInfoLogoLarge"><img src="Images/UserlogoLARGE.png" alt="User profile logo LARGE"/></div> <div id="profileTitle"><h2 class="shadow" title="Your Profile"><b>Your Profile</b></h2></div> </div><!--End of profileBar--> <div id="content-bodycontent"> <div id="Redcontentwindow"> <div class="Redwindowtop"> <div id="headerLogo"><img src="Images/PropertyManagerSMALL.png" alt="Property Manager"/></div> <span><h4>Property Manager</h4></span> </div> <div class="Redwindowbody"> <?php //Save any submitted data if ($stage > 1) { foreach ($_POST as $key => $value) { $_SESSION[$key] = $value; } } ?> <div id="submitCustomerForm"> <ul class="uploadProgress"> <li class="upload"><img src="Images/step1DONE.png" alt="Stage 1 - Your details"/></li> <li class="upload"><img src="Images/step2ACTIVE.png" alt="Stage 2 - House details"/></li> <li class="upload"><img src="Images/step3UNACTIVE.png" alt="Stage 3 - Image upload"/></li> <li class="upload"><img src="Images/step4UNACTIVE.png" alt="Property Manager complete"/></li> </ul> <hr /> <p class="largeblack"><strong>Step 2 - Your House Details</strong></p> <p class="largeblack"> Please fill in the room specifications and descriptions below </p> <?php if (isset($_SESSION['error_storage'])) { $strError = '<div class="formerror" style="width:100%;margin-left:0;"><p class="largeblue" style="margin:5px;"><strong><img src="/images/warningtriangle.png">Please check the following and try again:</strong></p><ul style="padding:0 5px 5px 20px;list-style:disc;">'; // Get each error and add it to the error string // as a list item. foreach ($_SESSION['error_storage'] as $error) { $strError .= "<li>$error</li>"; } $strError .= '</ul></div><br />'; echo $strError; } ?> <h7>Your House details</h7> <br /> <form action="stage2_process.php" method="post" name="upload_stage2"> <div class="inputfield"> <div<?php if(!empty ($_SESSION['error_storage']['propertyTypeEntry']) || !empty ($_SESSION['error_storage']['propertyType2Entry'])){ echo ' class="Emailerrorlabel"';} ?>> <label class="title" for="propertyType">Property type:</label> <select class="open" style="float:left;" name="propertyType2" id="propertyType2"> <option class="open" value="" <?php if($house_info['property_type2'] == ''){echo 'selected';}?>>--Please Select--</option> <option class="open" value="house" <?php if($house_info['property_type2'] == 'house'){echo 'selected';}?>>House</option> <option class="open" value="apartment" <?php if($house_info['property_type2'] == 'apartment'){echo 'selected';}?>>Apartment</option> <option class="open" value="Flat" <?php if($house_info['property_type2'] == 'Flat'){echo 'selected';}?>>Flat</option> </select> <select class="open" style="float:right;margin-right:170px;" name="propertyType" id="propertyType"> <option class="open" value="">--Please Select--</option> <option class="open" value="??">N/A</option> <option class="open" value="detached" <?php if($house_info['property_type'] == 'detached'){echo 'selected';}?>>Detached</option> <option class="open" value="semi-detached" <?php if($house_info['property_type'] == 'semi-detached'){echo 'selected';}?>>Semi-Detached</option> <option class="open" value="terraced" <?php if($house_info['property_type'] == 'terraced'){echo 'selected';}?>>Terraced</option> </select> <?php //if an email has not been entered then output emailEntry error if (!empty ($_SESSION['error_storage']['propertyTypeEntry']) || !empty ($_SESSION['error_storage']['propertyType2Entry'])){ echo '<img src="/images/warningtriangle.png" style="position:relative;left:155px;padding-top:3px;" alt=""><br /><span class="Emailerrortextlabel">'.$_SESSION['error_storage']['propertyTypeEntry'].'</span>'; }?> </div> </div> <div class="inputfield"> <div<?php if(!empty ($_SESSION['error_storage']['statusEntry']) || !empty ($_SESSION['error_storage']['propertyType2Entry'])){ echo ' class="Emailerrorlabel"';} ?>> <label class="title" for="status">Status:</label> <select class="open" name="status" id="status"> <option class="open" value="">--Please Select--</option> <option class="open" value="for sale" <?php if($house_info['status'] == 'for sale'){echo 'selected';}?>>For Sale</option> <option class="open" value="for rent" <?php if($house_info['status'] == 'for rent'){echo 'selected';}?>>For Rent</option> <option class="open" value="under negotiation" <?php if($house_info['status'] == 'under negotiation'){echo 'selected';}?>>Under Negotiation</option> </select> <?php //if an email has not been entered then output emailEntry error if (!empty ($_SESSION['error_storage']['statusEntry']) || !empty ($_SESSION['error_storage']['statusEntry'])){ echo '<img src="/images/warningtriangle.png" alt=""><br /><span class="Emailerrortextlabel">'.$_SESSION['error_storage']['statusEntry'].'</span>'; }?> </div> </div> <div class="inputfield"> <div<?php if(!empty ($_SESSION['error_storage']['priceEntry']) || !empty ($_SESSION['error_storage']['propertyType2Entry'])){ echo ' class="Emailerrorlabel"';} ?>> <label class="title" for="price">Asking Price:</label> £ <input class="open" name="price" type="text" size="20" maxlength="15" id="price" value="<?php echo $house_info['valuation'];?>" /> <?php //if an email has not been entered then output emailEntry error if (!empty ($_SESSION['error_storage']['priceEntry'])){ echo '<img src="/images/warningtriangle.png" alt=""><br /><span class="Emailerrortextlabel">'.$_SESSION['error_storage']['priceEntry'].'</span>'; }?> </div> </div> <div class="inputfield"> <div<?php if(!empty ($_SESSION['error_storage']['noofbedEntry']) || !empty ($_SESSION['error_storage']['noofbedEntry'])){ echo ' class="Emailerrorlabel"';} ?>> <label class="title" for="noofbed">No. of Bedrooms:</label> <select class="open" name="noofbed" id="noofbed" onchange="this.selectedIndex>0?create_fields(Number(this.value),'bedrooms'):null;"> <option class="open" value="">--Please Select--</option> <option class="open" value="1" <?php if($house_info['num_bedrooms'] == '1'){echo 'selected';}?>>One</option> <option class="open" value="2" <?php if($house_info['num_bedrooms'] == '2'){echo 'selected';}?>>Two</option> <option class="open" value="3" <?php if($house_info['num_bedrooms'] == '3'){echo 'selected';}?>>Three</option> <option class="open" value="4" <?php if($house_info['num_bedrooms'] == '4'){echo 'selected';}?>>Four</option> <option class="open" value="5" <?php if($house_info['num_bedrooms'] == '5'){echo 'selected';}?>>Five</option> <option class="open" value="6" <?php if($house_info['num_bedrooms'] == '6'){echo 'selected';}?>>Six</option> </select> <?php //if an email has not been entered then output emailEntry error if (!empty ($_SESSION['error_storage']['noofbedEntry'])){ echo '<img src="/images/warningtriangle.png" alt=""><br /><span class="Emailerrortextlabel">'.$_SESSION['error_storage']['noofbedEntry'].'</span>'; }?> </div> </div> <div class="inputfield"> <div<?php if(!empty ($_SESSION['error_storage']['noofbathEntry']) || !empty ($_SESSION['error_storage']['noofbathEntry'])){ echo ' class="Emailerrorlabel"';} ?>> <label class="title" for="noofbath">No. of Bathrooms:</label> <select class="open" name="noofbath" id="noofbath" onchange="this.selectedIndex>0?create_fields(Number(this.value),'bathrooms'):null;"> <option class="open" value="">--Please Select--</option> <option class="open" value="1" <?php if($house_info['num_bathrooms'] == '1'){echo 'selected';}?>>One</option> <option class="open" value="2" <?php if($house_info['num_bathrooms'] == '2'){echo 'selected';}?>>Two</option> <option class="open" value="3" <?php if($house_info['num_bathrooms'] == '3'){echo 'selected';}?>>Three</option> <option class="open" value="4" <?php if($house_info['num_bathrooms'] == '4'){echo 'selected';}?>>Four</option> <option class="open" value="5" <?php if($house_info['num_bathrooms'] == '5'){echo 'selected';}?>>Five</option> <option class="open" value="6" <?php if($house_info['num_bathrooms'] == '6'){echo 'selected';}?>>Six</option> </select> <?php //if an email has not been entered then output emailEntry error if (!empty ($_SESSION['error_storage']['noofbathEntry'])){ echo '<img src="/images/warningtriangle.png" alt=""><br /><span class="Emailerrortextlabel">'.$_SESSION['error_storage']['noofbathEntry'].'</span>'; }?> </div> </div> <br /> <h7 class="formHeader">Room details</h7> <div class="inputfield"> <p class="largeblack"><strong>Living Room</strong></p> <div class="dimensions"> <label class="room" for="livingroom_width">Dimensions:<br/> <span class="textSmallGreen">(in feet)</span> </label> <?php if($function == 'edit'){ $liv_query = mysql_query("SELECT room_width,room_length,description FROM rooms WHERE room_name = 'Living Room' AND house_id = '$house_id'"); $din_query = mysql_query("SELECT room_width,room_length,description FROM rooms WHERE room_name = 'Dining Room' AND house_id = '$house_id'"); $liv_rec = mysql_fetch_array($liv_query); $din_rec = mysql_fetch_array($din_query); }?> <input class="open" name="livingroom_width" id="livingroom_width" type="text" size="5" value="<?php echo $liv_rec['room_width'];?>" /> x <input class="open" name="livingroom_length" id="livingroom_length" type="text" size="5" value="<?php echo $liv_rec['room_length'];?>" /> </div> <div class="descriptionHolder"> <label class="room" style="width:90px;" for="livingroom_desc">Description:<br/> <span class="textSmallGreen">(max. 100 words)</span> </label> <textarea class="open" name="livingroom_desc" id="livingroom_desc" size="100" cols="35" rows="5" ><?php echo $liv_rec['description'];?> </textarea> </div> </div> <div class="inputfield"> <p class="largeblack"><strong>Dining Room</strong></p> <div class="dimensions"> <label class="room" for="diningroom_width">Dimensions:<br/> <span class="textSmallGreen">(in feet)</span> </label> <input class="open" name="diningroom_width" id="diningroom_width" type="text" size="5" value="<?php echo $din_rec['room_width'];?>" /> x <input class="open" name="diningroom_length" id="diningroom_length" type="text" size="5" value="<?php echo $din_rec['room_length'];?>" /> </div> <div class="descriptionHolder"> <label class="room" style="width:90px;" for="diningroom_desc">Description:<br/> <span class="textSmallGreen">(max. 100 words)</span> </label> <textarea class="open" name="diningroom_desc" id="diningroom_desc" size="100" cols="35" rows="5"><?php echo $din_rec['description'];?> </textarea> </div> </div> <div class="inputfield"> <img style="float:right;" src="Images/addRoom.png" alt="add another room" onclick="<?php echo 'generate_room();';$clickCount++;?>" /> <img id="deleteRoom" style="float:right; visibility:hidden; padding-right:4px;" src="Images/deleteRoom.png" alt="delete added room" onclick="remove_room('inputfield');" /> </div> <div id="rooms"><!--Start of rooms div--> </div><!--End of rooms div--> <br /> <div id="bedrooms"> <h7>Bedroom details</h7> <?php if($function == 'edit'){ $sql = "SELECT * FROM bedrooms WHERE house_id = '$house_id'"; $result = mysql_query($sql) or die("Failed to query bedrooms: ".mysql_error()); while($row = mysql_fetch_assoc($result)){ ?> <div class="inputfield"> <p class="largeblack"><strong>Bedroom_1</strong></p> <div class="dimensions"> <label class="room" for="bedrooms[1][]">Dimensions:<br/> <span class="textSmallGreen">(in feet)</span> </label> <input class="open" name="bedrooms[1][]" id="bedrooms[1][]" type="text" size="5" value="<?php echo htmlspecialchars($row['room_width']) ?>" /> x <input class="open" name="bedrooms[1][]" id="bedrooms[1][]" type="text" size="5" value="<?php echo htmlspecialchars($row['room_length']) ?>" /> </div> <div class="descriptionHolder"> <label class="room" style="width:90px;" for="bedrooms[1][]">Description:<br/> <span class="textSmallGreen">(max. 100 words)</span> </label> <textarea class="open" name="bedrooms[1][]" id="bedrooms[1][]" size="100" cols="35" rows="5"><?php echo htmlspecialchars($row['description']) ?></textarea> </div> </div> <?php } }else{ ?> <div class="inputfield"> <p class="largeblack"><strong>Bedroom_1</strong></p> <div class="dimensions"> <label class="room" for="bedrooms[1][]">Dimensions:<br/> <span class="textSmallGreen">(in feet)</span> </label> <input class="open" name="bedrooms[1][]" id="bedrooms[1][]" type="text" size="5" value="" /> x <input class="open" name="bedrooms[1][]" id="bedrooms[1][]" type="text" size="5" value="" /> </div> <div class="descriptionHolder"> <label class="room" style="width:90px;" for="bedrooms[1][]">Description:<br/> <span class="textSmallGreen">(max. 100 words)</span> </label> <textarea class="open" name="bedrooms[1][]" id="bedrooms[1][]" size="100" cols="35" rows="5"></textarea> </div> </div> </div> <br /> <div id="bathrooms"> <h7>Bathroom details</h7> <div class="inputfield"> <p class="largeblack"><strong>Bathroom_1</strong></p> <div class="dimensions"> <label class="room" for="bathrooms[1][]">Dimensions:<br/> <span class="textSmallGreen">(in feet)</span> </label> <input class="open" name="bathrooms[1][]" id="bathrooms[1][]" type="text" size="5" value="" /> x <input class="open" name="bathrooms[1][]" id="bathrooms[1][]" type="text" size="5" value="" /> </div> <div class="descriptionHolder"> <label class="room" style="width:90px;" for="bathrooms[1][]">Description:<br/> <span class="textSmallGreen">(max. 100 words)</span> </label> <textarea class="open" name="bathrooms[1][]" id="bathrooms[1][]" size="100" cols="35" rows="5">Enter your description here..... </textarea> </div> </div> </div> <br /> <h7>Extra Details</h7> <div class="inputfield"> <p class="largeblack"<strong>Garden</strong></p> <div class="dimensions"> <label class="room" for="garden_width">Dimensions:<br/> <span class="textSmallGreen">(in feet)</span> </label> <input class="open" name="garden_width" id="garden_width" type="text" size="5" value="" /> x <input class="open" name="garden_width" id="garden_length" type="text" size="5" value="" /> </div> <div class="descriptionHolder"> <label class="room" style="width:90px;" for="garden_desc">Description:<br/> <span class="textSmallGreen">(max. 100 words)</span> </label> <textarea class="open" name="garden_desc" id="garden_desc" size="100" cols="35" rows="5">Enter your description here..... </textarea> </div> </div> <br /> <h7>Overall Description</h7> <div class="inputfield"> <p class="largeblack"><strong>Property Description</strong></p> <p class="largeblack">This is your opportunity to really sell your house and make it sound as wonderful as possible!<br />You have 200 words to describe your house as a whole, giving details of features, entrances, style etc......<strong>good luck!</strong></p> <textarea class="open" style="position:relative;left:-90px;" name="property_desc" id="property_desc" cols="70" rows="5">Enter your description here..... </textarea> </div> <br /> <input type='hidden' name='added_rooms' value='<?php echo $clickCount ?>'/> <input name="Submit" type="image" align ="right" src="Images/NextButton.png" /> </form> </div> </div> <div class="Redwindowbottom"><span></span></div> </div> </div><!--End of content-bodycontent"--> </div> <div id="footer"> <ul id="footerMenu"> <li><a class="small" href="ConstructionPage.html">Go4home terms & conditions</a></li> <li><a class="small" href="ConstructionPage.html">Accessibility</a></li> <li><a class="small" href="ConstructionPage.html">About Us</a></li> <li><a class="small" href="ConstructionPage.html">Privacy Policy</a></li> <li><a class="small" href="ConstructionPage.html">Contact Us</a></li> </ul> <br /> <p class="copyright">© Go4home.co.uk 2007</p> <ul id="validationMenu"> <li><a href="http://jigsaw.w3.org/css-validator/"><img src="Images/vcss-blue.png" alt="Valid CSS!" /></a></li> <li><a href="http://validator.w3.org/check?uri=referer"><img src="Images/vxhtml.png" alt="Valid XHTML 1.0 Transitional!"/></a></li> </ul> </div> </div><!--End of mainContainer--> </body> </html> so if you want have a look through that..i think the method that you have suggested will work, and i don't know why i didn't think of doing that sooner, i guess i got side tracked with using the javascript with php thing and wanted to solve that, when i could made things a lot easier for myself! just let me know if have any questions about the code, hopefully you can get an idea of what i'm tyring to do by looking at this code.. cheers Craig Quote Link to comment Share on other sites More sharing options...
barbs75 Posted July 31, 2008 Author Share Posted July 31, 2008 hey!! and guess what? i used your idea and it works prefectly!!! i have wasted SO much time, god i feel rather annoyed! and relieved at the same time! cheers for your help!! Craig Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.