Heya!
I'm currently creating a MOD where you get more questions (fields) depending on which topic you select. So you will get different fields depending on which topic you select.
I'm ALMOST there but I made a test for fun, just to make sure selecting a topic still works.
Now I get an error "Unable to create a ticket. Please correct errors below and try again!" when choosing any topic when I fill out the form.
Do anyone want to help me with get this working? I think (and hope) that more ppl would like to have this working.
Thanks in advance!!!
Pasting my code here. (osticket/include/client/open.inc.php)
The Javascript:
<script type="text/javascript">
$(document).ready(function() {
$('#Rank').bind('change', function() {
var elements = $('div.container').children().hide(); // hide all the elements
var value = $(this).val();
if (value.length) { // if somethings' selected
elements.filter('.' + value).show(); // show the ones we want
}
}).trigger('change');
$('.second-level-select').bind('change', function() {
var elements = $('div.second-level-container').children().hide(); // hide all the elements
var value = $(this).val();
if (value.length) { // if somethings' selected
elements.filter('.' + value).show(); // show the ones we want
}
}).trigger('change');
});
</script>
The code:
<tr><td valign="top"><b>Typ av ärende:</td><td>
<select size="1" id="Rank" title="" name="topicId">
<option value="" selected >Välj här</option>
<?
$services= db_query('SELECT topic_id,topic FROM '.TOPIC_TABLE.' WHERE isactive=1 ORDER BY topic');
if($services && db_num_rows($services)) {
while (list($topicId,$topic) = db_fetch_row($services)){
$selected = ($info==$topicId)?'selected':''; ?>
<option value="<?=$topicId?>"<?=$selected?>><?=$topic?></option>
<?
}
}else{?>
<option value="0" >General Inquiry</option>
<?}?>
</select>
<font class="error">* <?=$errors?></font>
<div class="container">
<div class="3"><br><h3>OBS! Detta ärende kräver svar på nedan följdfrågor.</h3><br>
Hur är ytteremballage skadat?<br>
<textarea name="message1" cols="35" rows="3" wrap="soft" style="width%"></textarea><br><br>
Hur är inneremballage skadat?<br>
<textarea name="message2" cols="35" rows="3" wrap="soft" style="width%"></textarea><br><br>
Hur är produkten skadad?<br>
<textarea name="message3" cols="35" rows="3" wrap="soft" style="width%"></textarea>
</div>
<div class="4">
<select class="second-level-select">
<option value="">- Lager - en till Drop down? -</option>
<option value="val1">Val 1</option>
<option value="val2">Val 2</option>
</select>
</div>
<div class="5">
<br><h3>OBS! Detta ärende kräver svar på nedan följdfrågor.</h3><br>
Vänligen beskriv ditt fakturaärende.<br>
<textarea name="message4" cols="35" rows="3" wrap="soft" style="width%"></textarea>
</div>
<div class="6">
Kanske fler val till Övrigt?
</div>
</div>
</div>
So, the DIV class is the topicId. It recognizes the topicID and gives me the extra fields.
(yes I know, the extra fields aren't implemented yet, so it just shows u how it looks like)