Trigger second level DIV

Hey,
I’m using a script for hiding divs and show different divs depending on which Drop Down you choose.

So this script shows some text if I choose the Drop down with no. 1
And it shows two radiobuttons if I choose the Drop down with no. 2

The problem I have with this is that IF I get an error (due to missing info in any of the fields) the script doesn’t remember which DIV to show. So it simply shows nothing.

Here’s the link to the page: http://webbhjalpen.com/kund/frontline/open.php
Try with choosing “Typ av Ärende” - “Transportskada”
Then choose “Välj skadetyp” - “Synlig”

You will now see the radiobuttons showing up.

Now try to send away the form (press Skicka ärende) and you’ll see that the radiobuttons will disappear.

Anyone who knows how I can solve this?

Thanks!

[code][/code]

[php]
Välj här
<?
$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’]==$topicId)?‘selected’:’’; ?>
<option value="<?=$topicId?>"<?=$selected?>><?=$topic?>
<?} }else{?>
General Inquiry
<?}?>

<div class="3">
Välj skadetyp <? $transportskada= db_query('SELECT id,transportskada FROM '.TABLE_PREFIX.'transportskador ORDER BY transportskada'); while (list($id,$name) = db_fetch_row($transportskada)){ $valdtransportskada = ($info['transportskada']==$id)?'selected':''; ?> ><?=$name?> <? }?>
<div class="second-level-container">
<div class="1"><br><b>Tidsfrist:</b>
	<br>Advantage & EMO: 8dgr<br>Direct: 48h utan totalgaranti, 15dgr med totalgaranti.<br>
</div>
<div class="2">
	<br>Har kund noterat p&aring; kvittens?&nbsp;<font class="error">*&nbsp;<?=$errors['noterat']?></font><br>
	<?php
	$noterat = (isset($_POST['noterat']) ? $_POST['noterat'] : ""); // set either posted or default value
	?>
	<input name="noterat" type="radio" value="Ja"<?php echo ($noterat == "Ja" ? " checked=\"checked\"" : ""); ?> />Ja
	<input name="noterat" type="radio" value="Nej"<?php echo ($noterat == "Nej" ? " checked=\"checked\"" : ""); ?> />Nej
</div>
</div>[/php]

I couldn’t load the URL you posted.

I think since you are relying on POST data and not using AJAX, you will likely need to manually set the display style of each div. For example,

[php]<div style=“display:<?php echo ($myselect == "Synlig" ? "block" : "none"); ?>”>[/php]

Hey m@tt,

Thanks for your reply!

I couldn’t get this to work =/ Tried changing $myselect to $id like this:

[php]
Välj skadetyp
<?
$transportskada= db_query(‘SELECT id,transportskada FROM ‘.TABLE_PREFIX.‘transportskador ORDER BY transportskada’);
while (list($id,$name) = db_fetch_row($transportskada)){
$valdtransportskada = ($info[‘transportskada’]==$id)?‘selected’:’’; ?>
<option value="<?=$id?>" <?=$valdtransportskada?>><?=$name?>

</select>
&nbsp;<font class="error">*&nbsp;<?=$errors['transportskada']?></font>

<div class="second-level-container">
<div class="1" style="display:<?php echo ($id == "Synlig" ? "block" : "inline"); ?>"><br><b>Tidsfrist:</b>
	<br>Advantage & EMO: 8dgr<br>Direct: 48h utan totalgaranti, 15dgr med totalgaranti.<br>
</div>
<div class="2" style="display:<?php echo ($id == "Dold" ? "block" : "inline"); ?>">
	<br>Har kund noterat p&aring; kvittens?&nbsp;<font class="error">*&nbsp;<?=$errors['noterat']?></font><br>
	<?php
	$noterat = (isset($_POST['noterat']) ? $_POST['noterat'] : ""); // set either posted or default value
	?>
	<input name="noterat" type="radio" value="Ja"<?php echo ($noterat == "Ja" ? " checked=\"checked\"" : ""); ?> />Ja
	<input name="noterat" type="radio" value="Nej"<?php echo ($noterat == "Nej" ? " checked=\"checked\"" : ""); ?> />Nej
</div>
</div>
<?
	}?>[/php]

Also tried with changing the value none to inline, show etc just for testing

$myselect is going to be your posted variable. Since I couldn’t load your form I have no idea what that is.

It would be $_POST[‘myselect’]

I’m not so sure how to fix that then :frowning:

Could you try again please? I would really appreciate it.
It works for me to go to the form.

http://webbhjalpen.com/kund/frontline/open.php

Bump, I really want to get this fixed.
My last bugfix that needs to be done. :-*

I’m not entirely sure how you need to integrate this in your code.

I’m wondering why you are using “block” or “inline”? The purpose is to hide the divs that are not selected. If you need to use inline then you would use “inline” or “none”

[php]

<?php echo ($id == "Dold" ? "inline" : "none"); ?>[/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service