How to decode JSON javascript? [closed] - javascript

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'm newbie on Phonegap and Javascript. I'm trying to develop login example for android. I send username and password with Post Method to php file and get this json encoded output
{"tag":"login","success":"1","error":"0"},"name":"can","email":"can#can.com"}}
Here is my client side code
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<div style="padding:3px 2px;border-bottom:1px solid #ccc">Ajax Form</div>
<form id="ff" action="http://mehmetcantas.info/ogdtek/balance/index.php" method="post">
<table>
<tbody><tr>
<td>username : <input id="email" name="email" type="text"></td>
</tr>
<tr>
<td>password : <input id="password" name="password" type="password"></td>
</tr>
<tr>
<td><input type="hidden" name="tag" value="login"> </td>
</tr>
<tr>
<td>AffiliateLink : <input id="AffiliateLink" name="AffiliateLink" type="text"></td>
</tr>
<tr><td><input value="Submit" type="submit"></td>
</tr></tbody></table>
</form>
<script type="text/javascript">
$('#ff').form({
success:function(data){
$.messager.alert('Info', data, 'info');
}
});
</script>
I want to do if succes:1 then open welcome.html

This might work for you.
if (data.succes == '1') {
window.location="welcome.html";
}
else {
window.location="login.html";
}
PS: The json you provided is not valid.
{"tag":"login","success":"1","error":"0"},"name":"can","email":"can#can.com"}}
IT should be as below.
{"tag":"login","success":"1","error":"0","name":"can","email":"can#can.com"}

Related

Receive table values on click on different page [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have a table containing 2 columns named S.No. and Book. In S.No. Value 1 2 3... And in Book column there is a submit button for each row. If I click on first submit button then it should print 1 and if I click on 2nd submit button then it should print 2 on different page (data.php)
After you posted your table (in a comment!) I believe I understand what you want to achieve. I created two files, copy-pasted your code, and made some very little changes:
In "books.php" the submit buttons are enclosed in "form" tags.
"data.php" gets the book number from "$_POST".
Here are the files:
books.php
<table border="1">
<tr>
<th>S.No.</th>
<th>Book</th>
</tr>
<tr>
<td>1</td>
<td> <!-- THE BOOK NUMBER IS IN A HIDDEN FIELD OF THE FORM -->
<form method="post" action="data.php">
<input type="text" value="1" name="book" hidden>
<input type="submit" value="Submit">
</form>
</td>
</tr>
<tr>
<td>2</td>
<td> <!-- THE BOOK NUMBER IS IN A HIDDEN FIELD OF THE FORM -->
<form method="post" action="data.php">
<input type="text" value="2" name="book" hidden>
<input type="submit" value="Submit">
</form>
</td>
</tr>
</table>
data.php
<?php
// GET BOOK NUMBER FROM PREVIOUS PAGE.
if ( isSet( $_POST["book"] ) )
$book = $_POST["book"];
else $book = "";
?>
<form>
<label for="sno">S.No.</label>
<input type="text" value="<?php echo $book;?>"> <!-- DISPLAY BOOK NUMBER -->
<input type="submit" value="Submit">
</form>
What SHiV with JARVIS must do is to create two files with the given names, copy-paste previous code, open your browser and run localhost/books.php.

jQuery looking for a plugin to dynamically move tables and updates ID's accordingly [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I'm trying to find a way in jQuery to move dynamically tables.
I've coded actually a button to clone a hidden table when needed as well a button to delete a not needed table.
Now I'd like to add the function to change the order of those tables dynamically. But, I need the id's of the elements inside the table to be updated as well as the data will be used into a form (see sample).
<TABLE id="Leg0" width="400px" border="0">
<TR >
<TD><INPUT type="checkbox" class="delCheckLeg" name="chk"/></TD>
<TD><INPUT type="text" placeholder="Date" class="datepicker" id="tripdate0" name="tripdate0"/></TD>
<TD><INPUT type="text" placeholder="Dep Time" id="deptime0" name="deptime0"/></TD>
<TD><INPUT type="text" placeholder="Departure" class="aptsearch" id="routingdep0" name="routingdep0"/></TD>
<TD><INPUT type="text" placeholder="Arrival" class="aptsearch" id="routingarr0" name="routingarr0"/></TD>
<TD><INPUT type="text" placeholder="Flight Time" id="fttime0" name="fttime0"/></TD>
<TD><INPUT type="text" placeholder="Pax" id="pax0" name="pax0"/></TD>
</TR>
</TABLE>
<TABLE id="Leg1" width="400px" border="0">
<TR >
<TD><INPUT type="checkbox" class="delCheckLeg" name="chk"/></TD>
<TD><INPUT type="text" placeholder="Date" class="datepicker" id="tripdate1" name="tripdate1"/></TD>
<TD><INPUT type="text" placeholder="Dep Time" id="deptime1" name="deptime1"/></TD>
<TD><INPUT type="text" placeholder="Departure" class="aptsearch" id="routingdep1" name="routingdep1"/></TD>
<TD><INPUT type="text" placeholder="Arrival" class="aptsearch" id="routingarr1" name="routingarr1"/></TD>
<TD><INPUT type="text" placeholder="Flight Time" id="fttime1" name="fttime1"/></TD>
<TD><INPUT type="text" placeholder="Pax" id="pax1" name="pax1"/></TD>
</TR>
</TABLE>
I've tried to use a system with arrows to move the tables up and down but it would be more nice with a dragging solution. For such thing, I've seen the pluggin "Table Drag and Drop JQuery plugin" but it seems to work only with rows&columns.
Does anyone have an idea on how to perform this?
You can go with slickgrid. Slickgrid is open source library and has nice documentation and examples

Make Div enter a search value [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
I would like to make this div tag "tile 1" to be selectable and upon clicking it retrieves search results based on a key word.
<div id="tile1" class="live-tile" data-swap="image" data-direction="horizontal" data-stops="80px,90%,100%,90%,0" data-delay="6000">
<div>
<img class="full" src="../bakeware2.png" alt="2" />
</div>
<div>
<img class="full" src="../bakeware3.png" alt="3" />
</div>
</div>
Here is the code that I use for my search bar.
<table align="center">
<tr>
<td align="center"><form action='search.asp' method='post'>
<div style="float:left;">
<input type="search" style="color:#000;" name="keyword" size="30" data-mini="true" value="bakeware">
</div>
<div style="float:left;">
<input type=image src="http://www.kitchenova.com/assets/templates/v32029/images/btn-search.gif" border="0" />
</form></td>
</tr>
</table>
Is there a way I can make the div "tile1" click-able and have it display the results as if I were to type in say "cookies" in the actual search bar itself?
Is this FIDDLE what you're looking for?
JS
$('.clickme').click(function(){
var typeaword = $('#getme').val();
typeaword = '123' + typeaword + 'xyz';
$('.putmehere').html(typeaword);
});

Need to duplicate code [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 8 years ago.
Improve this question
So guys I have a code that outputs text boxes and the information will be saved.
<tbody id="1111111">
<tr>
<td class="ObjektiivneLeid">The function</td>
<td class="Hinnang">
<input class="Hinnang_Valimata" type="radio" name="1111111_Hinnang" value="Valimata" id="1111111_Hinnang_Valimata" />Valimata
<input class="Hinnang_norm" type="radio" name="1111111_Hinnang" id="364644000_Hinnang_NORM" value="NORM" />NORM
<input class="Hinnang_pat checkbox_idParent" type="radio" name="1111111_Hinnang" id="1111111_Hinnang_Patoloogia" value="Patoloogia"/>Leid</td>
<td class="Patoloogia">kuupäev
<input id="1111111_otherInfo_kuupaev" name="1111111_otherInfo_kuupaev" type="text" value="" class="Patoloogia_text" onFocus="gnlGotFocus(getCurrentDate(),this);"
onKeyDown="javascript:gnlKeyDown('00.00.0000',this,event);" maxlength='10'
onblur="javascript:gnlDateValid(this,event,false);"/></td>
</tr>
<tr>
<td class="title_sub Patoloogia">sight</td>
<td class="Patoloogia"><input id="1111111_otherInfo_sight" name="1111111_otherInfo_sight" type="text" value="" class="Patoloogia_text"></td>
</tr>
<tr>
<td class="title_sub Patoloogia">hearing</td>
<td class="Patoloogia"><input id="364644000_otherInfo_hearing" name="364644000_otherInfo_hearing" type="text" value="" class="Patoloogia_text"></td>
<td class="title_sub Patoloogia">speech</td>
<td class="Patoloogia"><input id="1111111_otherInfo_speech" name="1111111_otherInfo_speech" type="text" value="" class="Patoloogia_text"></td>
</tr>
<tr>
<td class="title_sub Patoloogia">mobility</td>
<td class="Patoloogia"><input id="1111111_otherInfo_mobility" name="1111111_otherInfo_mobility" type="text" value="" class="Patoloogia_text"></td>
<td class="title_sub Patoloogia">movement</td>
<td class="Patoloogia"><input id="1111111_otherInfo_movement" name="1111111_otherInfo_movement" type="text" value="" class="Patoloogia_text"></td>
</tr>`
So this is the code that gives me boxes to fill in and I need to make a adding system to that code, so when I press i.e. '+' it will duplicate the code and I have new fields to fill and save. Also I need and 'x' button to erase the new field if the need comes. Any suggestions how would I go by doing it (I hope my explanation wasn't to confusing)
I need something like <tr><td colspan="4"><img src="./images/addButton.gif" alt="Add" border="0" onclick="" class="button" /></td></tr> but I dont know what to pud in the onClick....I know it seems stupid but I really could use some help
If I understood you correctly, you would be needing JQuery. Looking for something like this?
$(document).ready(function() {
var dupe = $('#parent_0').clone();
var id = 1;
$(document).on('click', '#plus', function() {
id++;
var newForm = $(dupe).clone().attr('id', 'parent_'+id);
$('body').append(newForm);
});
$(document).on('click', '#delete', function() {
id--;
$('[id^="parent_"]:last').remove();
});
});
I have made a JSFiddle based on your code for you to have a look at.
For demonstration purposes a div is used. There should be a form tag around your code since it actually is a form, but it seems JSFiddle doesn't like the use of forms in it's application. This div element will be cloned with .clone() and is given a unique attribute with .attr() when the button #plus is clicked.
#delete deletes the last clone element in the document whose id starts with parent_.
When you're posting stuff, make sure you paste the whole thing in the question.
Use appendChild(n) and removeChild(n) on the parent object containing the text boxes.

Wiping out default text when user will enter a username [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I want to use JavaScript to wipe out default text and allow user to enter a his choice word. How do I integrate this thing with my HTML code. I need it for testing purpose. Below is my HTML code.
<html>
<body bgcolor="black"><form method="get" action ="http://localhost:2013">
<center>
<font color="white" size=65>Enter Word:
<input type="text" name="word"></font></center>
</br><center>
<font color="Green" size=65>
<input type="submit" value="SUBMIT"></font></center><
form>
</body>
</html>
Any suggestions?
<!DOCTYPE html>
<body bgcolor="black"><form method="get" action ="http://localhost:2013">
<center>
<font color="white" size=65>Enter Word:
<input type="text" name="word" placeholder='Default Text'></font></center>
</br><center>
<font color="Green" size=65>
<input type="submit" value="SUBMIT"></font></center><
form>
</body>
</html>
Just add placeholder='Default Text' to your input element.
No need of much items, this will help you...
<form action="demo_form">
<input type="text" name="fname" placeholder="Your default text"><br>
<input type="text" name="lname" placeholder="Your default text"><br>
</form>

Categories