Click here to Skip to main content
12,942,930 members (42,896 online)
Rate this:
 
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 5:19am
Updated 11-Oct-12 2:57am
v3
Comments
Sergey Alexandrovich Kryukov 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 10-Oct-12 12:55pm
   
Will Javascript picks up the value like this?
No need to mention document.getElementById().value?
DaveAuld 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 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
Top Experts
Last 24hrsThis month
OriginalGriff 4,565
CHill60 2,860
Maciej Los 2,178
Jochen Arndt 1,900
ppolymorphe 1,755


Advertise | Privacy | Mobile
Web02 | 2.8.170518.1 | Last Updated 11 Oct 2012
Copyright © CodeProject, 1999-2017
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