Jump to content

underlink

Members
  • Posts

    10
  • Joined

  • Last visited

underlink's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Never mind, the problem was with the MYSQL table not sure what but i deleted it and recreated it and all started working
  2. Thanks I acctualy got it working doing something like that. However It has caused another issue. When I try and copy the code onto another dropdown menu (obviously altering the values the second one does not work. It is most likly a stupid error I am not spotting <tr id="<?php echo $id; ?>" class="edit_tr"> <!-- Title Colum --><td class="style4" style="font-size:14px;width:200; height:35px; class="edit_td"> Type: </td> <td style="font-size:14px;width:270px;border:solid 0px #000;padding:0px; class="edit_td"> <span style="color:#0066CC;" id="type1_<?php echo $id; ?>" class="text"><?php echo $Type; ?></span> <!-- ***************************************START - This Is the dropdown menu script *********************************************** --> <script type="text/javascript"> function OnDropDownChange2(dropDown) { var selectedValue = dropDown.options[dropDown.selectedIndex].value; document.getElementById("type1_input_<?php echo $id; ?>").value = selectedValue; } </script> <select name = "MYtype" selected="selected" id="type1_input_<?php echo $id; ?>" class="editbox" onChange="OnDropDownChange2(this);"> <?php $sql = mysql_query("SELECT LType FROM LST_Type"); while ($row = mysql_fetch_array($sql)){ if ($row['LType'] == $Type) { echo "<option Selected='selected' value=" . $row["LType"] . ">" . $row['LType'] . "</option>"; } else echo "<option value=" . $row["LType"] . ">" . $row['LType'] . "</option>"; } ?> </select> <input type="text" value="<?php echo $Type; ?>" class="editbox" id="type1_input_<?php echo $id; ?>" /> /> I changed the $Type to $Cond (as well as other "type" attributes the list for Cond (short for Condition) is in a lable called LST_Cond with a column "LCond" can anyone spot why this wont work the second time around (on the same page)
  3. Not sure how to go about this task but I imagine it requires some sort of foreach loop I have a drop down list populated by a label called LST_Type, this table only exists to provide options for this dropdown list The value selected on the dropdown menu gets written to a table called "assets". when the users clicks away from the form (using ajax) Here is what I need to happen: On page load the dropdown list need its default option to be whatever the current value of the record is in the "asset" table. As the only way you can insert data into this field is via the dropdown list it will always be somethig from the "LST_Type" table The reason is that the data is written to the fields when you click away from the input boxes and unless you are editing the "Type" record it updates it to its default selection. hope this makes sense here is my code: <tr id="<?php echo $id; ?>" class="edit_tr"> <!-- Title Colum --><td class="style4" style="font-size:14px;width:200; height:35px; class="edit_td"> Type: </td> <td style="font-size:14px;width:270px;border:solid 0px #000;padding:0px; class="edit_td"> <span style="color:#0066CC;" id="type1_<?php echo $id; ?>" class="text"><?php echo $Type; ?></span> <!-- ***************************************START - This Is the dropdown menu script *********************************************** --> <script type="text/javascript"> function OnDropDownChange2(dropDown) { var selectedValue = dropDown.options[dropDown.selectedIndex].value; document.getElementById("type1_input_<?php echo $id; ?>").value = selectedValue; } </script> <select name = "MYtype" id="type1_input_<?php echo $id; ?>" class="editbox" onChange="OnDropDownChange2(this);">> <?php $sql = mysql_query("SELECT Type FROM LST_Type"); while ($row = mysql_fetch_array($sql)){ echo "<option value='" . $row['Type'] . "'>" . $row['Type'] . "</option>"; } ?> </select> <input type="text" value="<?php echo $Type; ?>" class="editbox" id="type1_input_<?php echo $id; ?>" /> /> <!-- ***************************************END *********************************************** -->
  4. Sorry about duplicating title from old post. Stupid Chromes fault
  5. Not sure how to go about this task but I imagine it requires some sort of foreach loop I have a drop down list populated by a label called LST_Type, this table only exists to provide options for this dropdown list The value selected on the dropdown menu gets written to a table called "assets". when the users clicks away from the form (using ajax) Here is what I need to happen: On page load the dropdown list need its default option to be whatever the current value of the record is in the "asset" table. As the only way you can insert data into this field is via the dropdown list it will always be somethig from the "LST_Type" table The reason is that the data is written to the fields when you click away from the input boxes and unless you are editing the "Type" record it updates it to its default selection. hope this makes sense here is my code: <tr id="<?php echo $id; ?>" class="edit_tr"> <!-- Title Colum --><td class="style4" style="font-size:14px;width:200; height:35px; class="edit_td"> Type: </td> <td style="font-size:14px;width:270px;border:solid 0px #000;padding:0px; class="edit_td"> <span style="color:#0066CC;" id="type1_<?php echo $id; ?>" class="text"><?php echo $Type; ?></span> <!-- ***************************************START - This Is the dropdown menu script *********************************************** --> <script type="text/javascript"> function OnDropDownChange2(dropDown) { var selectedValue = dropDown.options[dropDown.selectedIndex].value; document.getElementById("type1_input_<?php echo $id; ?>").value = selectedValue; } </script> <select name = "MYtype" id="type1_input_<?php echo $id; ?>" class="editbox" onChange="OnDropDownChange2(this);">> <?php $sql = mysql_query("SELECT Type FROM LST_Type"); while ($row = mysql_fetch_array($sql)){ echo "<option value='" . $row['Type'] . "'>" . $row['Type'] . "</option>"; } ?> </select> <input type="text" value="<?php echo $Type; ?>" class="editbox" id="type1_input_<?php echo $id; ?>" /> /> <!-- ***************************************END *********************************************** -->
  6. At some point i will create an SQL table to populate the dropdown but for now I am happy to just use prepopulated data to test with what I need to happen is for the selection made on the dropdown menu to be written back to the database on selection. I have it working for text boxes (defines as <input> tags) here is the live data : http://www.underlink.co.uk/AssetManager/Live_edit/asset.php?test=Asset+3
  7. Ok I have another question about the same code (I am putting the second question here to save reuploading all the code to a different post) I want to make my input box into a dropdown box. for the purpose of the test it can be manual populated but with the AJAX there I cant make it work the code line is <input type="text" value="<?php echo $Type; ?>" class="editbox" id="type1_input_<?php echo $id; ?>" /> </td> I tried <select class="editbox" id="model1_input_<?php echo $id; ?>"/> <option value= value="<?php echo $Model; ?>">1</option> <option value="2">2</option> <option value="3">3</option> </select> </td> </tr> But this only turned it into a dropdown but will not populate the record with the selected data from the list Any help would be really helpful
  8. Muddy you are my new best friend, my hero... oh hell your my everything!!!! I love you so much I that was it I cant believe it was something so silly as the name of the field. Thank you so much
  9. Yes you are correct, but the original code had the quote and still did not work. quote is wmissing as I typoed when posting the question. Thank for the reply though but still no luck
  10. I am building an asset managment system, utilizing some code I found on the net which does live record updates using AJAX, the code is great if I rememeber the link I will post it. However the example code only contains database fields and I need about 14ish, so with my little understanding of the code i started adding more fields. for some reason every time I try to insert the "condition" field the live update stops working for all fields. you can type in new data but does not save back to the database. It happends when i change the code from this: $sql = "update fullnames set AssetID='$AssetID',SerialNumber='$SerialNumber',Type='$Type',Model='$Model' ,Location='$Location' ,Make='$Make' where id='$id'"; mysql_query($sql); to this $sql = "update fullnames set AssetID='$AssetID',SerialNumber='$SerialNumber',Type='$Type',Model='$Model' ,Location='$Location' ,Condition='$Condition ,Make='$Make' where id='$id'"; mysql_query($sql); the full code is attached. I would really apprisiate any help assets.php table_ajax_edit.php
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.