Jump to content

badeand

Members
  • Posts

    34
  • Joined

  • Last visited

Everything posted by badeand

  1. Here is the form code. It stores the ID from another row in the mysql database instead of the value of the this row. It should get the value from another mysql table but instead it gets the ID of the row that it should get the value from.. <script type="text/javascript"> function confirmSubmit(){ var r=confirm("Er du sikker på at du vil sende skjema?"); if(r) return true; return false; } </script> <script type="text/javascript"> function addNewCase() { $('#afterdiv').after('<fieldset><legend>Legg til Utstyr <a href="#r" onclick="removeCase(this);" style="font-size: 11px">(x)Slett</a></legend><div><div class="item"><label for="case">Type Sak</label><select name="fields['+currentval+'][case]" id="case"><option value="">Vennligst velg type sak</option><? $q=mysql_query("select * from fields where type='case_type'") or die(mysql_error()); while($r=mysql_fetch_array($q)) { ?><option value="<?=$r['id']?>"><?=$r['value']?></option><? } ?></select></div><div class="item"><label for="error">Feilmelding</label><select name="fields['+currentval+'][error]" id="error"><option value="">Vennligst velg feilmelding</option><? $q=mysql_query("select * from fields where type='error_message'") or die(mysql_error()); while($r=mysql_fetch_array($q)) { ?><option value="<?=$r['id']?>"><?=$r['value']?></option><? } ?></select></div><div><label for="other">Annen feil</label><textarea name="fields['+currentval+'][other]" id="other" rows="12" cols="30"></textarea></div><label>Innlevert Utstyr</label></br></br><div class="item"><label for="hardwareid">Hardware ID</label><input type="text" name="fields['+currentval+'][hardwareid]" value="" size="30" class="hardwareid" id="fields['+currentval+'][hardwareid]"></div><div class="item"><label for="hardware">Demontert Modell</label><select name="fields['+currentval+'][hmodel]" id="fields['+currentval+'][hmodel]" class="hmodel"><option value="">Vennligst velg type utstyr</option><? $q=mysql_query("select * from fields where type='hardware_model'") or die(mysql_error()); while($r=mysql_fetch_array($q)) { ?><option value="<?=$r['id']?>"><?=$r['value']?></option><? } ?></select></br></div></br></br><label>Erstatnings utstyr</label></br><br><div class="item"><label for="hardwarerep">Hardware ID</label><input type="text" name="fields['+currentval+'][hardwarerep]" class="hardwarerep" value="" size="30" id="hardwarerep"></div><div class="item"><label for="replacement">Monetert Modell</label><select name="fields['+currentval+'][replacement]" id="fields['+currentval+'][replacement]" class="rmodel"><option value="">Vennligst velg type utstyr</option><? $q=mysql_query("select * from fields where type='replacement_model'") or die(mysql_error()); while($r=mysql_fetch_array($q)) { ?><option value="<?=$r['id']?>"><?=$r['value']?></option><? } ?></select></div></div></fieldset>'); currentval++; } function removeCase(el) { $(el).parent().parent().remove(); currentval--; } $(".hardwareid").live('blur', function() { var hi = $(this).attr('id').replace("fields[", "").replace("][hardwareid]",""); $.post("select.php", { hardid: $(this).val() ,type: 'id' }, function(data) { $('.hmodel').each(function() { if($(this).attr("id") == "fields["+hi+"][hmodel]") { $(this).find("option[value='"+data+"']").attr("selected",true); } }); }); }); $(".hardwarerep").live('blur', function() { var hi = $(this).attr('name').replace("fields[", "").replace("][hardwarerep]",""); $.post("select.php", { hardid: $(this).val(),type: 'rep' }, function(data) { $('.rmodel').each(function() { if($(this).attr("id") == "fields["+hi+"][replacement]") { $(this).find("option[value='"+data+"']").attr("selected",true); } }); }); }); </script>
  2. Could anyone help me and see why the script stores the ID into "replacement" row instead of the value from the form. If needed i can post the form script. ANY help would be appreciated Here is the process code <? include("db.php"); echo "<pre>"; foreach($_POST['fields'] as $items) { $qcheck1= mysql_query("select * from fields where id='".$items['hmodel']."'") or die(mysql_error()); $rcheck1=mysql_fetch_array($qcheck1); $hmodel = $rcheck1['value']; $qcheck2= mysql_query("select * from fields where id='".$items['case']."'") or die(mysql_error()); $rcheck2=mysql_fetch_array($qcheck2); $case = $rcheck2['value']; $qcheck3= mysql_query("select * from fields where id='".$items['error']."'") or die(mysql_error()); $rcheck3=mysql_fetch_array($qcheck3); $error = $rcheck3['value']; $q=mysql_query("INSERT INTO `customer_data` (`id`, `name`, `number`, `address`, `case`, `hmodel`, `error`, `other`, `hardwareid`, `replacement`, `hardwarerep`) VALUES (NULL, '".mysql_real_escape_string($_POST['name'])."', '".mysql_real_escape_string($_POST['number'])."', '".mysql_real_escape_string($_POST['address'])."', '".mysql_real_escape_string($case)."', '".mysql_real_escape_string($hmodel)."', '".mysql_real_escape_string($error)."', '".mysql_real_escape_string($items['other'])."', '".mysql_real_escape_string($items['hardwareid'])."', '".mysql_real_escape_string($items['replacement'])."', '".mysql_real_escape_string($items['hardwarerep'])."')") or die(mysql_error()); echo "<br> Din registrering har ID : ".mysql_insert_id(); } ?>
  3. Hi, I´m making a system that´s is meant to store information about some hardware and the different kind of error messages and fault that appears on the hardware. Each hardware has is it`s own unique hardware ID and it`s the last 4 digits in the Hardware ID ( serial number). Is there a way that i can detect wich hardware this is by making the php script looking for the 4 last digits in the serial and lookup this in a mysql table (that contains the different equipment and information about this) and pick the right equipment and then redirect to the right error handling page with the specified form for this equipment? Each equipment has it own error messages and known errors, so one error (form) for each equipment is needed.
×
×
  • 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.