Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Hi friends
 
I'm new to Mvc 3 Razor engine, i have a question. If i have to 4 text boxes having 2 textboxes for firstname and 2 textboxes for second name.
FirstName: @Model.reser_fname
LastName: @Model.reser_lname
(modifyname)
FirstName: @Model.reser_fname
LastName: @Model.reser_lname
(modifyname)
// script for popup box when the modify link is clicked
<script type="text/javascript">
$(document).ready(function () {
$('#modify').click(function () {
$("#dialog:ui-dialog").dialog("destroy");
$("#dialog-box").dialog({
buttons: {
"save": function () {
},
Cancel: function () {
$(this).dialog("close");
}}
});
});
});
</script>
// div inside the popup box

Edit Details
FirstName : <input type="text" id="reser_fname" />
LastName : <input type="text" id="reser_lname" />
this is on a confirmation page, where as per razor code i have the first name and last name, now if i want to edit the first and last name,i click modify and i get a popup box, which has firstname and lastname. I enter i the details and click save button inside the popup. So the details on the confirmation page should change. how is that i can write a code for that save button where it changes the details on my confirmation page.
 
can anyone help..
Posted 10-Oct-12 6:19am
Edited 11-Oct-12 3:57am
v3
Comments
Sergey Alexandrovich Kryukov at 10-Oct-12 16:20pm
   
No, it should not! Never repeat yourself.
--SA

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

The simplest option is just to use javascript to copy across;
 
<!DOCTYPE html>
 
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title></title>
</head>
<body>
    <p>
        Textbox 1 (FirstName):<input id="Text1" onchange="text1Change()" type="text" /></p>
    <p>
        Textbox 2 (LastName):<input id="Text2" onchange="text2Change()" type="text" /></p>
 
    <p>
        Textbox 3 (FirstName Copy):<input id="Text3" type="text" /></p>
    <p>
        Textbox 4 (LastName Copy)<input id="Text4" type="text" /></p>
 
    <script type="text/javascript">
 
        function text1Change() {
            Text3.value = Text1.value;
        }
 
        function text2Change() {
            Text4.value = Text2.value;
 
        }
 
    </script>
</body>
</html>
  Permalink  
Comments
Arunprasath Natarajan at 10-Oct-12 12:55pm
   
Will Javascript picks up the value like this?
No need to mention document.getElementById().value?
DaveAuld at 10-Oct-12 13:01pm
   
I copied and pasted the code straight from a test page I chucked together to test this. There are other methods you could also use, like kepress events to do the trigger, or bind through jQuery.
I tested this in chrome (works), but it doesn't work in IE, so you will need to tweak to make it cross browser.
Arunprasath Natarajan at 10-Oct-12 23:30pm
   
K tan q.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 6,569
1 Sergey Alexandrovich Kryukov 6,168
2 DamithSL 5,228
3 Manas Bhardwaj 4,717
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web01 | 2.8.1411022.1 | Last Updated 11 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100