This topic is locked

Display Field with javascript

10/28/2010 8:25:34 PM
PHPRunner General questions
P
pimelimar author

Dear all,
With the HTML code below the text field "Enter more information for Choice 1" displays when the checkbox "Choice 1" is checked.

For my application with PHPRUNNER 5.2 I would like to get the same result with my "Add Form".
Please explain me how can I adapt this HTML code (including the javascript)
Best regard
Pierre
**

This is my code:
<body>

<form method="post" action="">

<label for="name">Name</label> : <input type="text" name="name" id="name" /><br /> <p>
<script type="text/javascript">

function choiceClic(el)

{

var elchoice = el.form.elements['choice'], choice = null;

for(var i=0; i<elchoice.length; i++)

{

if(elchoice[i].checked) choice = elchoice[i].value;

}

document.getElementById('block1').style.display = (choice == 'ant') ? 'block' : 'none';

document.getElementById('block2').style.display = (choice == 'mod') ? 'block' : 'none';

}

</script>
<input type="checkbox" name="choice" value="ant" id="ant" onclick="choiceClic(this)" />

<label for="ant">Choice 1 </label>

<p name="block1" id="block1" style="display: none;">

<label for="morechoice1"> Enter more information for Choice 1</label> : <input type="text" name="morechoice1" id="morechoice1" /> </p>
<input type="checkbox" name="choice" value="mod" id="mod" onclick="choiceClic(this)" /><label for="mod">Choice 2 </label>

<p name="block2" id="block2" style="display: none;">

<label for="morechoice2">Enter more information for Choice 2</label> : <input type="text" name="morechoice2" id="morechoice2" />

</form>

</body>

Admin 10/28/2010

I would suggest to check this example that falls pretty close to what you trying to build:

http://xlinesoft.com/phprunner/docs/show_dropdown_list_of_us_states.htm

P
pimelimar author 10/29/2010



I would suggest to check this example that falls pretty close to what you trying to build:

http://xlinesoft.com/phprunner/docs/show_dropdown_list_of_us_states.htm


Dear Admin,
Thank you for your answer. I have try the "Show dropdown list of US states..." example by creating a table with 2 fields "country" and "state" and puting the javascript. When selecting US as country, nothing happens. Do I miss a step?

Please help me.
Best regards
Pierre

Admin 10/29/2010

You might be missing a step of field names are not spelled properly (case-sensitive).
If nothing helps post your application to Demo Account and open a ticket at http://support.xlinesoft.com sending your Demo Account URL. 'Demo Account' button can be found on the last screen in the program.