below is the original code, and
<html>
<head>
<title>slider</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="slider-container">
<form action="asd.php" method="GET">
<input type="range" min="0" max="10" value="5" id="slider">
</form>
<div id="selector">
<div class="SelectBtn1"></div>
<div id="SelectValue"></div>
</div>
<div id="Progressbar"></div>
</div>
<div class="nextcontainer">
Result »
</div>
the asd.php
<body>
<div class="result-head">
<h1 class="main-title ng-binding">Your excrement..</h1>
</div>
<div class="result-container">
<h1 class="area">can support annually<?php echo $_REQUEST['slider'];?></h1>
</div>
</body>
I made html file and php file, and I tried to get response from the survey and try to show it in the next page(asd.php)
However, when I input and surf the next page, it shows pure code like the picture. What did I do wrong?
You have to use the attribute name instead of the attribute id because that is how it is passed on. For example you could do
<html>
<head>
<title>slider</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="slider-container">
<form action="asd.php" method="GET">
<input type="range" min="0" max="10" value="5" id="slider" name="slider">
</form>
<div id="selector">
<div class="SelectBtn1"></div>
<div id="SelectValue"></div>
</div>
<div id="Progressbar"></div>
</div>
<div class="nextcontainer">
Result »
</div>
Related
full code here : https://codepen.io/asmoun0801/pen/mGegjw
<div class="">
<p>Certifiée :</p>
<!-- Rounded switch -->
<label class="switch">
<input type="checkbox">
<span class="slider round"></span>
</label>
</div>
If I'm getting this right, you should place the <input> element inside a
<form method="POST" action=""> ... </form>
element in order to be able to POST it to a PHP server. Also you should set the name attribute of the input field.
css : https://codepen.io/asmoun0801/pen/eLJOXg
solution html :
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<?php if(isset($_POST['cert'])){
echo $cert[0] ;
}
?>
<form action="action.php" method="post">
<div class="">
<p>Certifiée :</p>
<!-- Rounded switch -->
<label class="switch">
<input type="checkbox" name="cert[]" value="true">
<span class="slider round"></span>
</label>
</div>
</form>
</body>
</html>
I have an html with submit button.
Submit sends you to php.
php code has this:
header("location:./setupOk.html");
$html = file_get_html('setupOk.html');
$ret = $html->find('div[id=valueOk]');
echo $ret[0]->innertext = "foo";
and this is some of my html setupOk.html code:
<form action="http://54.186.92.18/Pixel-Matrix/keys.php" method="post">
<div class="logo">
<link rel="stylesheet" type="text/css" href="styles.css">
<label id="logo"</label>
<!--<label for="name">Type:</label>-->
</div>
<div class="right">
<h1>Enter License Information</h1>
<div id="valueOk">
<input type="text" id="valOk" name="Key" readonly="readonly" />
</div>
</div>
<div class="button">
<button id="validateB" type="submit">Validate Now ></button>
</div>
</form>
After executing button on first html, it goes to php and reloads my html website with setupOk but no text is innered to anywhere. Any solution?
EDIT:
my goal is to have a general html (with label and images) then from php, put text to that html and automatically load this html on user's browser
EDIT2:
MY FIRST HTML ISN'T THE SAME THAN 2ND HTML. FIRST ONE SENDS POST PETITION TO PHP THEN DEPENDING ON THE INFO SENT TO PHP, PHP WILL FILL TEXT TO THE 2ND HTML AND LOAD THIS LAST HTML ON USER'S BROWSER
Avoiding DOMParser and loading/redirecting to HTML page -- you can do it more simple way like (it has to be a PHP file):
<?php
$innerText = "";
if (!empty($_POST['Key'])) {
$innerText = "foo";
}
?>
<div class="logo">
<link rel="stylesheet" type="text/css" href="styles.css">
<label id="logo"</label>
<!--<label for="name">Type:</label>-->
</div>
<div class="right">
<h1>Enter License Information</h1>
<div id="valueOk">
<input type="text" id="valOk" name="Key" readonly="readonly" value="<?php echo $innerText;?>"/>
</div>
</div>
<div class="button">
<button id="validateB" type="submit">Validate Now ></button>
</div>
If you think this is not what you want - please elaborate your need a bit.
UPDATE
setupOk.php
<form action="http://54.186.92.18/Pixel-Matrix/keys.php" method="post">
<div class="logo">
<link rel="stylesheet" type="text/css" href="styles.css">
<label id="logo"</label>
<!--<label for="name">Type:</label>-->
</div>
<div class="right">
<h1>Enter License Information</h1>
<div id="valueOk">
<input type="text" id="valOk" name="Key" readonly="readonly" />
</div>
</div>
<div class="button">
<button id="validateB" type="submit">Validate Now ></button>
</div>
</form>
keys.php [where you are submitting the form]
require_once('simple_html_dom.php');
$processedResult = "";
if (!empty($_POST['Key'])) {
$processedResult = "foo";
}
$html = file_get_html('setupOk.php');
$html->find('input[id=valOk]', 0)->value = $processedResult;
echo $html;
I have tested it and it's working.
I want to submit an app using phonegap, My app uses a lot of php which i know apple do not like so much and just decline the app and say its best to have a web app. I have an example index.html here
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<title>
</title>
<link rel="stylesheet" href="css/logout-button.min.css" />
<link rel="stylesheet" href="css/jquery.mobile-1.3.0.min.css" />
<link rel="stylesheet" href="css/my.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
</script>
<script src="js/jquery.mobile-1.3.0.min.js"></script>
<script src="js/jquery.cookies.2.2.0.min.js"></script>
<script type="text/javascript">
var uid = $.cookies.get( 'uid' );
if(uid == null)
{
window.location ='account-login.html'; }
else
{ }
</script>
</head>
<body>
<div data-role="page" id="index4">
<div data-theme="a" data-role="header">
<a data-role="button" data-direction="reverse" data-rel="back" data-transition="slide"
data-icon="arrow-l" data-iconpos="left" class="ui-btn-left">
Back
</a>
<h3>
Event Details
</h3>
</div>
<div data-role="content">
<form id="eventForm" name="eventForm">
<div data-role="fieldcontain">
<fieldset data-role="controlgroup">
<label for="event">
Event
</label>
<input name="eventname" id="eventname" placeholder="eventname" value="" type="text" />
</fieldset>
</div>
<div data-role="fieldcontain">
<fieldset data-role="controlgroup">
<label for="about">
About
</label>
<textarea name="about" id="about" placeholder="about" value=""></textarea>
</fieldset>
</div>
<div data-role="fieldcontain">
<label for="dates">
Choose Dates
</label>
<div id="with-altField"></div>
<input type="hidden" id="altField" name="dates">
</fieldset>
</div>
<div data-role="fieldcontain">
<fieldset data-role="controlgroup">
<label for="enddate">
End Date
</label>
<div id="with-altfield1"></div>
<input type="hidden" id="altField1" name="enddate">
</fieldset>
</div>
<div data-role="fieldcontain">
<script>
$.get('event-details.php', function(data){
$('#yourdiv').html(data);
});
</script>
<div id="yourdiv"></div>
</div>
<div data-role="fieldcontain">
<label for="manual">Add Emails</label>
<textarea cols="40" rows="8" name="emails" id="emails"></textarea>
</div>
<input type="submit" value="Submit" id="submitEventButton">
</form>
</div>
</div>
</body>
</html>
I call event-details.php here
<?
require_once("../backend/functions.php");
dbconn();
$id = $CURUSER["id"];
$res = "SELECT username,email,status FROM users left join cal_contacts on cal_contacts.contactid = users.id WHERE cal_contacts.userid = $id";
$res1 = mysql_query($res);
?>
<label for="select-choice-1" class="select">
Choose Contacts:
</label>
<select name="contacts[]" id="contacts" multiple="multiple" data-native-menu="false">
<?
while($row = mysql_fetch_array($res1))
{
print "<option value=$row[email]>$row[email] ($row[status])</option>";
}
?>
</select>
<?
I have the select-menu created through php. I was wondering if there was another way to do this so the complete select html doesn't have to be on the php script. This would mean that it would be harder for me to change my app once submitted and i'm sure apple would accept it alot easier.
If your problem is just to remove the PHP processing on that HTML, you could just move it somewhere else as a web service then get it via ajax request. Then you can just use json, etc. to fetch the data and populate your select menu.
here is a doc on jquery! regarding how to make ajax requests.
i found a tutorial here which seem similar on what you want to achieve.
How To Write A Simple PHP/MySQL Web Service for an iOS App!
Okay.. this is the file lo_add.php:
<div class="rowElem">
<label>Item <? echo $i ?>:</label>
<div class="formRight searchDrop">
<select name="lo_item[]" class="chzn-select" data-placeholder="Choose an Item">
<option value=""></option>
<? $item_query = mysql_query("select id,code,title,price from items where domain_id='$domain_id' order by code");
while ($items = mysql_fetch_array($item_query)) { ?>
<option value="<? echo $items["id"] ?>"><? echo $items["code"]." - ".$items["title"]." - RM".$items["price"] ?></option>
<? } ?>
</select>
</div>
<label>Delivery Address :</label>
<div class="formRight searchDrop">
<select name="lo_site[]" class="chzn-select" data-placeholder="Choose a Delivery Address">
<option value=""></option>
<? $site_query = mysql_query("select id,name from sites where domain_id='$domain_id' order by name");
while ($sites = mysql_fetch_array($site_query)) { ?>
<option value="<? echo $sites["id"] ?>"><? echo $sites["name"] ?></option>
<? } ?>
</select>
</div>
<div class="fix"></div>
<label>Quantity:<span class="req">*</span></label>
<div class="formRight onlyNums">
<input type="text" name="lo_quantity[]" id="lo_quantity[]"/>
</div>
<div class="fix"></div>
</div>
And this is the html file that calls the css and what have you in the beginning:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<title>Mecacom Technologies® Maintenance System © 2012</title>
<link href="/css/main.css" rel="stylesheet" type="text/css" />
<link href='http://fonts.googleapis.com/css?family=Cuprum' rel='stylesheet' type='text/css' />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="js/plugins/wizards/jquery.validate.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#addElement').click(function() {
var data = '';
$.get('/ajax/lo_add.php', data, function(response){
$('#hello').append(response);
});
});
});
</script>
</head>
<body>
<div class="content" id="container">
<div class="title"><h5>Record New Local Order</h5></div>
<form action="<? echo $PHP_SELF ?>?add=1" id="valid" class="mainForm" method="post" enctype="multipart/form-data">
<fieldset>
<div class="widget">
<div class="head"><h5 class="iLocked2">New Local Order Credentials</h5></div>
<div class="rowElem noborder">
<label>Order ID:<span class="req">*</span></label>
<div class="formRight">
<input type="text" class="validate[required]" name="order_id" id="order_id"/>
</div>
<div class="fix"></div>
</div>
<div class="rowElem noborder">
<label>Order Date:<span class="req">*</span></label>
<div class="formRight">
<input type="text" name="order_date" class="datepicker validate[required]" />
</div>
<div class="fix"></div>
</div>
<div id="hello"></div>
<div class="fix"></div>
Click To Append More Item
<input type="submit" value="Next" class="greyishBtn submitForm" />
<div class="fix"><input type="hidden" name="addnow" value="1" /></div>
</div>
</fieldset>
</form>
</div>
</body>
</html>
sigh .. quite a handful ... How do you think that the css aren't being rendered correctly after the jquery append?
I can see from your live test page that you are using Chosen to process the dropdowns and jQuery validation plugin to validate the quantity field.
The first thing is to make sure you call chosen() on the newly created dropdowns. This has to be called for new elements, because Chosen doesn't only rely on CSS, but changes the entire HTML structure of the dropdowns. So add this line, following your append,
$(".chzn-select").chosen()
Second is to make sure you validate the newly created quantity textfields by calling validate() on them, or re-calling whatever javascript you called to initialize the validate plugin.
I have got a html like this:
<!doctype html>
<html manifest="">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script>
</head>
<body>
<div data-role="page" id="Find">
<div data-theme="b" data-role="header" data-position="fixed">
<h3>test</h3>
</div>
<div data-role="content">
<form action="handler.php" id="findForm" >
<div data-role="fieldcontain">
<fieldset data-role="controlgroup">
<label for="textinputf1"> keyword: </label> <input id="textinputf1" name="keyword" placeholder="" value="" type="text" />
</fieldset>
</div>
<input type= "submit" data-theme="g" value="Find" />
</form>
</div>
</div>
<div data-role="page" id="Results">
<div data-theme="b" data-role="header" data-position="fixed">
<h3>Results</h3>
</div>
<div data-role="content">
<ul data-role="listview" data-filter="true">
<li>HEllo</li>
<li>Bye</li>
</ul>
</div>
</div>
</body>
</html>
a handler.php like this:
<?php
//...
if( let's say false ) {
header("location:.");
}else{
header("location:./#Results");
//header("Refresh:0;url=/application/test/#Results");
}
with header+refresh or with header+location, when I submit the form, I see this in url bar:
.../handler.php?keyword=test
but I'm not redirected, and if I refresh the page (hit enter from the url bar or F5) THEN I get to the #Results, but not automatically
any idea how to fix that?
jquery mobile probably uses ajax to handle your form. You should switch of ajax handling for the form
jQuery Mobile form sample
Also put a space in your location
Location: whereyouwanttogo
Way to see the passed parameters without refresh is by putting data-ajax="false"
If you wish to use ajax, do not call urls directly. Call these with AJAX and based on response redirect to #Results with the help of JavaScript.