I have the following Problem
I get a variable from PHP via:
echo $var
Actually this takes place in:
<a href:"..\test.php?go=<?php echo $var ?>">
And to a page where you can get more info about $var...
Today i learned about the display attribute from a div, so i can display the info via Ajax direct in my actual page. So, I tried:
<Label id="123" onclick="doJS(<?php echo $var ?>)> Click ME </Label>
But this doesn't work, I cant click the label, just nothing happens.
How can this be solved?
You have a typo in your code.
Replace
<Label id="123" onclick="doJS(<?php echo $var ?>)> Click ME </Label>
By
<Label id="123" onclick="doJS(<?php echo $var ?>)"> Click ME </Label>
So you should try:
<label id='123' onclick="doJS(<?=$_GET['go']?>)"> Click ME </label>
Related
I have 2 check boxes and I want to keep the check box value after page refresh too. I mean if I enable a check box and after I submit the form if I navigate back or refresh the page it should be enable only.
I tried this but not working.
<input type="checkbox" id="enable1" name="check[0]" value= "1"
<?php if (in_array("0", $_POST['check'])) echo "checked='checked'"; ?> />
<input type="checkbox" id="enable2" name="check[1]" value= "1"
<?php if (in_array("1", $_POST['check'])) echo "checked='checked'"; ?> />
Please help me with this how to keep the state of check boxes after page reload
thanks..
My issue is once user click submit the form should check for all questions that the radio button is checked.
It should show the err message on the questions where the user didn't answer.
But right now the form refreshed everytime after the err message is shown and the
previous checked radio button is lost.I also have javascript timer going on,but
since the page get refreshed ,the timer starts all over again.
Im newbie to php,kindly guide me through this issue.Any help is appreciated.
<?php session_start()?>
<?php
$errorexist=false;
if (isset($_POST["submit"])){
for ($y=0;$y<5;$y++)
{
if(empty($_POST["question".$y])){
$errorexist=true;
${"err".$y}="* Please answer question ".($y+1)."<br>";
}
}
if (errorexist==false){
header ("Location: result.php");
exit;}
} ?>
html part of the code
<li>
<span class="error"><?php echo $err0?></span>
<h3>What is the smallest prime number?</h3>
<input type="radio" name="question0" value="A"<?php echo ($question0=='A')? 'checked':''; ?> />2<br>
<input type="radio" name="question0" value="B"<?php echo ($question0=='B')? 'checked':''; ?> />1<br>
<input type="radio" name="question0" value="C"<?php echo ($question0=='C')? 'checked':''; ?> />3<br>
<input type="radio" name="question0" value="D"<?php echo ($question0=='D')? 'checked':''; ?> />4<br>
</li>
Put a condition, where if any radio button misses it displays the
error message and no need to refresh the page. Inside the PHP code,
Request submit button
Request all the radio button. i.e $question1 = $_REQUEST['question1'];
check if all the values are set and not empty if(isset($question1) && !empty($question1) && $question1 !== '')
do this for all, close this condition with the error message.
This might help.
I am using the built-in Magento form validation to ensure the user makes a selection on a particular group of radio boxes.
The code below looks fine however
<div class="input-box">
<li class="control">
<input type="radio" class="radio organisation_type" value="1" id="billing:organisation_type_1" name="billing[organisation_type]"> <?php echo $this->__('School') ?></li>
<li class="control">
<input type="radio" class="radio organisation_type" value="2" id="billing:organisation_type_2" name="billing[organisation_type]"> <?php echo $this->__('Parent') ?></li>
<li class="control">
<input type="radio" class="radio validate-one-required organisation_type" value="3" id="billing:organisation_type_3" name="billing[organisation_type]"> <?php echo $this->__('Business') ?></li>
</div>
I am using the validate-one method on the class on the last radio box
For some reason the code above will only let me proceed if I select the last radio box?? Can anyone explain why if I check either the first or second box the validation is still failing?
You need to add validate-one-required-by-name to the last radio button.
<input type='radio' class="validate-one-required-by-name .. "
Take a look at Payment Method when placing an admin order
You can't use the same ID in any case. Make your input id attributes always different.
I have made a form in which a person puts up his details.
After completing the form and submitting it, I want a popup which should ask "Do you want to add more?","Yes or No ?".
If Yes is chosen, the some values filled in the form should be retained and the rest should appear blank.
On NO the page should get freshened with everything blank.
I am able to retain the values of the drop down items and text fields,but I am not able to retain the values of the check box items.
My check box code :
<label>Hotel Facilities</label>
</td><td class="row1"> :</td> <td class="row1" width="70%">
<div style=" font-weight:normal; color: #4B4B4B;font-size: 12px; width:260px; background:#D2D2D2; max-height:300px; overflow:scroll;overflow-x:hidden;">
<?php $dcs=mysql_query("select * from `tblfacility` where `Type`='Rm'");
while($dc=mysql_fetch_array($dcs)){?>
<input type="checkbox" name="check_list[]" value="<?php echo $dc['FId']; ?>">
<?php echo $dc['Facility'];?> <br />
<?php }?>
</div>
I tried to retain by using:
<input name="check_list[]" type="checkbox" value="<?php echo $dc['FId']; ?>" <?php if(isset($_POST['check_list[]'])) echo "checked='checked'"; else echo $dc['Facility']; ?>
but it did not worked
Please help me how to retain its values after submitting that page.
And the pop up I am at present using is just an alert message and hence it just have OK button:
<?php
if(isset($_POST['submit'])){
echo "<script>alert ('Do You want to Add More ?');</script>";
$HId=$_POST['HId'];
?>
hence it is just showing OK button after submitting .
Please guide how to put Yes or No button after submitting hence is Yes some values will be retained and if NO the whole from will be refreshed.
Instead of checked='checked' just use "selected" or "selected=true". I hope it works!
I'm hoping a javascript / jquery guru can help me out.
I'm trying to figure out a way to launch a popup box (fancybox) from the click of a checkbox label. I don't want to effect the checkbox function which filters data when clicked.
I would welcome any thoughts on how I can make this happen. I've tried an onclick function on the label but that doesn't work.
I want to show a fancybox when you click on a persons name in the checkbox label. Here's the site:- (example: jonathanlyon)
http://monkeygetnews.jonathanlyon.com/bs.php
The checkboxes are built dynamically and I need to create a click event on the label that opens a fancybox. Here's the code to build the checkboxes:-
<input type="checkbox" id = "dn" value="dept_<?php echo $currdept;?>" onchange="doSearch();return false;" />
<label><?php echo $currdept;?></label>
<ul class="dept_<?php echo $currdept;?>">
<li>
<input type="checkbox" name = "un" value="<?php echo $usernames;?>" <?php echo $include;?> onchange="doSearch();return false;" />
<label><?php echo $usernames;?></label>
</li>
<?php
$dept = $currdept;
} else {
?>
<li>
<input type="checkbox" name = "un" value="<?php echo $usernames;?>" <?php echo $include;?> onchange="doSearch();return false;" />
<label><?php echo $usernames;?></label>
</li>
<?php
$dept = $currdept;
}
?>
Thanks
Jonathan
Very simply put you can use jquery like this
$('label').click(function() {
alert($(this).html());
}
again, this is a very simple example and would need improvement
You need to wrap checkbox tag with label tag to make label clickable like
<label><input type="checkbox" name="checkbox" value="value"/>dasfaha</label>
Edit:
Sorry guys. I didn't look carefully. Here is how to detect label or checkbox.
How it works is that when you click unbounded label, checkbox won't be changed. However, when you click checkbox, ':checked' will be changed. Thus, you can put a variable to store previous value of checked, then compare with current checked.
http://jsfiddle.net/Xtyah/